More Books
Hibernate: A J2EE Developer's Guide
Hibernate: A J2EE™ Developer's Guide
Table of Contents
Copyright
Acknowledgments
About the Author
Preface
Required Skills
Roadmap
Chapter 1. Overview
Why Object/Relational Mapping?
What Is Hibernate?
Comparing JDBC to Hibernate
Hibernate's Mapping System
Other Java/Database Integration Solutions
How to Obtain and Install
Supported Databases
Chapter 2. Getting Oriented
Application Architecture
Mapping Files
Generating Java Source
Application Configuration
Web Application
JSP Interface
Chapter 3. Starting from Java
Java Object Model
Generated Mapping Files
Generated Schema
Working with Artifacts and Owners
Chapter 4. Starting from an Existing Schema
Initial Schema
Using Middlegen
Generated Mapping Files
Generated Java
Working with the Database
Chapter 5. Mapping Files
Basic Structure
Mapping File Reference
Chapter 6. Persistent Objects
Sessions
Objects and Identity
Life-Cycle Methods
Chapter 7. Relationships
Database Relationships
Java Collection Relationships
Java Class Relationships
Any-Based Relationships
Bi-directional Relationships
Chapter 8. Queries
HQL
HQL Reference
Select
From
Where
Group By
Having
Order By
Criteria Queries
Native SQL Queries
Chapter 9. Transactions
Introduction to Transactions
Optimistic and Pessimistic Locking
Chapter 10. Performance
Finding and Solving Problems
Queries
Inserts
Connection Pooling
Caching
Chapter 11. Schema Management
Updating an Existing Schema
Generating Update and Drop Scripts
Chapter 12. Best Practices, Style Guide, Tips and Tricks
Reducing Code with Inversion of Control
Reducing Session Creation Impact with ThreadLocal
Using Hibernate as an EJB BMP Solution
Integrating with Other Technologies
Applications That Use Hibernate
Strategies for Getting Started
Chapter 13. Future Directions
Hibernate 3.0
EJB 3.0
Here and Now
Index
SYMBOL
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X

Chapter 5. Mapping Files

As can be seen from the examples in Chapters 1 through 4, the *.hbm.xml files are at the heart of an application's use of Hibernate. Depending on your needs, you may or may not work with *.hbm.xml files directly (for example, you may prefer to work with Java code and use XDoclet, as shown in Chapter 3, or to start from an existing database, as shown in Chapter 4), but it's vital to understand the structure and options available in a *.hbm.xml mapping files. The options presented in XDoclet and Middlegen are based on the options available in these mapping files.

This chapter is intended as a reference, organized alphabetically, by tag. A description of each tag is included, as well as some notes and comments on usage where appropriate. If you are just orienting yourself to Hibernate, you may wish to skip or skim this chapter and instead go on to the conceptual elements and tools covered in the remainder of this book. Regardless, at some point you will almost certainly need to consult this reference to make full use of Hibernate or to understand the meaning of one or another attribute.

The vast majority of the tags discussed in this chapter deal with relationship management. For an overall view of the Java and database relationship strategies supported by Hibernate, consult Chapter 7.