Jump To Close Expand all Collapse all Table of contents Hibernate Core Reference Guide 1. Introduction 2. Tutorial Expand section "2. Tutorial" Collapse section "2. Tutorial" 2.1. Part 1 - The first Hibernate Application Expand section "2.1. Part 1 - The first Hibernate Application" Collapse section "2.1. Part 1 - The first Hibernate Application" 2.1.1. Setup 2.1.2. The first class 2.1.3. The mapping file 2.1.4. Hibernate configuration 2.1.5. Building with Maven 2.1.6. Startup and helpers 2.1.7. Loading and storing objects 2.2. Part 2 - Mapping associations Expand section "2.2. Part 2 - Mapping associations" Collapse section "2.2. Part 2 - Mapping associations" 2.2.1. Mapping the Person class 2.2.2. A unidirectional Set-based association 2.2.3. Working the association 2.2.4. Collection of values 2.2.5. Bi-directional associations 2.2.6. Working bi-directional links 2.3. Part 3 - The EventManager web application Expand section "2.3. Part 3 - The EventManager web application" Collapse section "2.3. Part 3 - The EventManager web application" 2.3.1. Writing the basic servlet 2.3.2. Processing and rendering 2.3.3. Deploying and testing 2.4. Summary 3. Architecture Expand section "3. Architecture" Collapse section "3. Architecture" 3.1. Overview 3.2. Instance states 3.3. JMX Integration 3.4. JCA Support 3.5. Contextual sessions 4. Configuration Expand section "4. Configuration" Collapse section "4. Configuration" 4.1. Programmatic configuration 4.2. Obtaining a SessionFactory 4.3. JDBC connections 4.4. Optional configuration properties Expand section "4.4. Optional configuration properties" Collapse section "4.4. Optional configuration properties" 4.4.1. SQL Dialects 4.4.2. Outer Join Fetching 4.4.3. Binary Streams 4.4.4. Second-level and query cache 4.4.5. Query Language Substitution 4.4.6. Hibernate statistics 4.5. Logging 4.6. Implementing a NamingStrategy 4.7. XML configuration file 4.8. J2EE Application Server integration Expand section "4.8. J2EE Application Server integration" Collapse section "4.8. J2EE Application Server integration" 4.8.1. Transaction strategy configuration 4.8.2. JNDI-bound SessionFactory 4.8.3. Current Session context management with JTA 4.8.4. JMX deployment 5. Persistent Classes Expand section "5. Persistent Classes" Collapse section "5. Persistent Classes" 5.1. A simple POJO example Expand section "5.1. A simple POJO example" Collapse section "5.1. A simple POJO example" 5.1.1. Implement a no-argument constructor 5.1.2. Provide an identifier property (optional) 5.1.3. Prefer non-final classes (optional) 5.1.4. Declare accessors and mutators for persistent fields (optional) 5.2. Implementing inheritance 5.3. Implementing equals() and hashCode() 5.4. Dynamic models 5.5. Tuplizers 5.6. EntityNameResolvers 6. Basic O/R Mapping Expand section "6. Basic O/R Mapping" Collapse section "6. Basic O/R Mapping" 6.1. Mapping declaration Expand section "6.1. Mapping declaration" Collapse section "6.1. Mapping declaration" 6.1.1. Doctype 6.1.2. Hibernate-mapping 6.1.3. Class 6.1.4. id 6.1.5. Enhanced identifier generators 6.1.6. Identifier generator optimization 6.1.7. composite-id 6.1.8. Discriminator 6.1.9. Version (optional) 6.1.10. Timestamp (optional) 6.1.11. Property 6.1.12. Many-to-one 6.1.13. One-to-one 6.1.14. Natural-id 6.1.15. Component and dynamic-component 6.1.16. Properties 6.1.17. Subclass 6.1.18. Joined-subclass 6.1.19. Union-subclass 6.1.20. Join 6.1.21. Key 6.1.22. Column and formula elements 6.1.23. Import 6.1.24. Any 6.2. Hibernate types Expand section "6.2. Hibernate types" Collapse section "6.2. Hibernate types" 6.2.1. Entities and values 6.2.2. Basic value types 6.2.3. Custom value types 6.3. Mapping a class more than once 6.4. SQL quoted identifiers 6.5. Metadata alternatives Expand section "6.5. Metadata alternatives" Collapse section "6.5. Metadata alternatives" 6.5.1. Using XDoclet markup 6.5.2. Using JDK 5.0 Annotations 6.6. Generated properties 6.7. Auxiliary database objects 7. Collection mapping Expand section "7. Collection mapping" Collapse section "7. Collection mapping" 7.1. Persistent collections 7.2. Collection mappings Expand section "7.2. Collection mappings" Collapse section "7.2. Collection mappings" 7.2.1. Collection foreign keys 7.2.2. Collection elements 7.2.3. Indexed collections 7.2.4. Collections of values and many-to-many associations 7.2.5. One-to-many associations 7.3. Advanced collection mappings Expand section "7.3. Advanced collection mappings" Collapse section "7.3. Advanced collection mappings" 7.3.1. Sorted collections 7.3.2. Bidirectional associations 7.3.3. Bidirectional associations with indexed collections 7.3.4. Ternary associations 7.3.5. Using an <idbag> 7.4. Collection examples 8. Association Mappings Expand section "8. Association Mappings" Collapse section "8. Association Mappings" 8.1. Introduction 8.2. Unidirectional associations Expand section "8.2. Unidirectional associations" Collapse section "8.2. Unidirectional associations" 8.2.1. Many-to-one 8.2.2. One-to-one 8.2.3. One-to-many 8.3. Unidirectional associations with join tables Expand section "8.3. Unidirectional associations with join tables" Collapse section "8.3. Unidirectional associations with join tables" 8.3.1. One-to-many 8.3.2. Many-to-one 8.3.3. One-to-one 8.3.4. Many-to-many 8.4. Bidirectional associations Expand section "8.4. Bidirectional associations" Collapse section "8.4. Bidirectional associations" 8.4.1. one-to-many / many-to-one 8.4.2. One-to-one 8.5. Bidirectional associations with join tables Expand section "8.5. Bidirectional associations with join tables" Collapse section "8.5. Bidirectional associations with join tables" 8.5.1. one-to-many / many-to-one 8.5.2. one to one 8.5.3. Many-to-many 8.6. More complex association mappings 9. Component Mapping Expand section "9. Component Mapping" Collapse section "9. Component Mapping" 9.1. Dependent objects 9.2. Collections of dependent objects 9.3. Components as Map indices 9.4. Components as composite identifiers 9.5. Dynamic components 10. Inheritance mapping Expand section "10. Inheritance mapping" Collapse section "10. Inheritance mapping" 10.1. The three strategies Expand section "10.1. The three strategies" Collapse section "10.1. The three strategies" 10.1.1. Table per class hierarchy 10.1.2. Table per subclass 10.1.3. Table per subclass: using a discriminator 10.1.4. Mixing table per class hierarchy with table per subclass 10.1.5. Table per concrete class 10.1.6. Table per concrete class using implicit polymorphism 10.1.7. Mixing implicit polymorphism with other inheritance mappings 10.2. Limitations 11. Working with objects Expand section "11. Working with objects" Collapse section "11. Working with objects" 11.1. Hibernate object states 11.2. Making objects persistent 11.3. Loading an object 11.4. Querying Expand section "11.4. Querying" Collapse section "11.4. Querying" 11.4.1. Executing queries 11.4.2. Filtering collections 11.4.3. Criteria queries 11.4.4. Queries in native SQL 11.5. Modifying persistent objects 11.6. Modifying detached objects 11.7. Automatic state detection 11.8. Deleting persistent objects 11.9. Replicating object between two different datastores 11.10. Flushing the Session 11.11. Transitive persistence 11.12. Using metadata 12. Transactions and Concurrency Expand section "12. Transactions and Concurrency" Collapse section "12. Transactions and Concurrency" 12.1. Session and transaction scopes Expand section "12.1. Session and transaction scopes" Collapse section "12.1. Session and transaction scopes" 12.1.1. Unit of work 12.1.2. Long conversations 12.1.3. Considering object identity 12.1.4. Common issues 12.2. Database transaction demarcation Expand section "12.2. Database transaction demarcation" Collapse section "12.2. Database transaction demarcation" 12.2.1. Non-managed environment 12.2.2. Using JTA 12.2.3. Exception handling 12.2.4. Transaction timeout 12.3. Optimistic concurrency control Expand section "12.3. Optimistic concurrency control" Collapse section "12.3. Optimistic concurrency control" 12.3.1. Application version checking 12.3.2. Extended session and automatic versioning 12.3.3. Detached objects and automatic versioning 12.3.4. Customizing automatic versioning 12.4. Pessimistic locking 12.5. Connection release modes 13. Interceptors and events Expand section "13. Interceptors and events" Collapse section "13. Interceptors and events" 13.1. Interceptors 13.2. Event system 13.3. Hibernate declarative security 14. Batch processing Expand section "14. Batch processing" Collapse section "14. Batch processing" 14.1. Batch inserts 14.2. Batch updates 14.3. The StatelessSession interface 14.4. DML-style operations 15. HQL: The Hibernate Query Language Expand section "15. HQL: The Hibernate Query Language" Collapse section "15. HQL: The Hibernate Query Language" 15.1. Case Sensitivity 15.2. The from clause 15.3. Associations and joins 15.4. Forms of join syntax 15.5. Referring to identifier property 15.6. The select clause 15.7. Aggregate functions 15.8. Polymorphic queries 15.9. The where clause 15.10. Expressions 15.11. The order by clause 15.12. The group by clause 15.13. Subqueries 15.14. HQL examples 15.15. Bulk update and delete 15.16. Tips & Tricks 15.17. Components 15.18. Row value constructor syntax 16. Criteria Queries Expand section "16. Criteria Queries" Collapse section "16. Criteria Queries" 16.1. Creating a Criteria instance 16.2. Narrowing the result set 16.3. Ordering the results 16.4. Associations 16.5. Dynamic association fetching 16.6. Example queries 16.7. Projections, aggregation and grouping 16.8. Detached queries and subqueries 16.9. Queries by natural identifier 17. Native SQL Expand section "17. Native SQL" Collapse section "17. Native SQL" 17.1. Using a SQLQuery Expand section "17.1. Using a SQLQuery" Collapse section "17.1. Using a SQLQuery" 17.1.1. Scalar queries 17.1.2. Entity queries 17.1.3. Handling associations and collections 17.1.4. Returning multiple entities 17.1.5. Returning non-managed entities 17.1.6. Handling inheritance 17.1.7. Parameters 17.2. Named SQL queries Expand section "17.2. Named SQL queries" Collapse section "17.2. Named SQL queries" 17.2.1. Using return-property to explicitly specify column/alias names 17.2.2. Using stored procedures for querying 17.3. Custom SQL for create, update and delete 17.4. Custom SQL for loading 18. Filtering data Expand section "18. Filtering data" Collapse section "18. Filtering data" 18.1. Hibernate filters 19. XML Mapping Expand section "19. XML Mapping" Collapse section "19. XML Mapping" 19.1. Working with XML data Expand section "19.1. Working with XML data" Collapse section "19.1. Working with XML data" 19.1.1. Specifying XML and class mapping together 19.1.2. Specifying only an XML mapping 19.2. XML mapping metadata 19.3. Manipulating XML data 20. Improving performance Expand section "20. Improving performance" Collapse section "20. Improving performance" 20.1. Fetching strategies Expand section "20.1. Fetching strategies" Collapse section "20.1. Fetching strategies" 20.1.1. Working with lazy associations 20.1.2. Tuning fetch strategies 20.1.3. Single-ended association proxies 20.1.4. Initializing collections and proxies 20.1.5. Using batch fetching 20.1.6. Using subselect fetching 20.1.7. Using lazy property fetching 20.2. The Second Level Cache Expand section "20.2. The Second Level Cache" Collapse section "20.2. The Second Level Cache" 20.2.1. Cache mappings 20.2.2. Strategy: read only 20.2.3. Strategy: read/write 20.2.4. Strategy: nonstrict read/write 20.2.5. Strategy: transactional 20.2.6. Cache-provider/concurrency-strategy compatibility 20.3. Managing the caches 20.4. The Query Cache 20.5. Understanding Collection performance Expand section "20.5. Understanding Collection performance" Collapse section "20.5. Understanding Collection performance" 20.5.1. Taxonomy 20.5.2. Lists, maps, idbags and sets are the most efficient collections to update 20.5.3. Bags and lists are the most efficient inverse collections 20.5.4. One shot delete 20.6. Monitoring performance Expand section "20.6. Monitoring performance" Collapse section "20.6. Monitoring performance" 20.6.1. Monitoring a SessionFactory 20.6.2. Metrics 21. Toolset Guide Expand section "21. Toolset Guide" Collapse section "21. Toolset Guide" 21.1. Automatic schema generation Expand section "21.1. Automatic schema generation" Collapse section "21.1. Automatic schema generation" 21.1.1. Customizing the schema 21.1.2. Running the tool 21.1.3. Properties 21.1.4. Using Ant 21.1.5. Incremental schema updates 21.1.6. Using Ant for incremental schema updates 21.1.7. Schema validation 21.1.8. Using Ant for schema validation 22. Example: Parent/Child Expand section "22. Example: Parent/Child" Collapse section "22. Example: Parent/Child" 22.1. A note about collections 22.2. Bidirectional one-to-many 22.3. Cascading life cycle 22.4. Cascades and unsaved-value 22.5. Conclusion 23. Example: Weblog Application Expand section "23. Example: Weblog Application" Collapse section "23. Example: Weblog Application" 23.1. Persistent Classes 23.2. Hibernate Mappings 23.3. Hibernate Code 24. Example: Various Mappings Expand section "24. Example: Various Mappings" Collapse section "24. Example: Various Mappings" 24.1. Employer/Employee 24.2. Author/Work 24.3. Customer/Order/Product 24.4. Miscellaneous example mappings Expand section "24.4. Miscellaneous example mappings" Collapse section "24.4. Miscellaneous example mappings" 24.4.1. "Typed" one-to-one association 24.4.2. Composite key example 24.4.3. Many-to-many with shared composite key attribute 24.4.4. Content based discrimination 24.4.5. Associations on alternate keys 25. Best Practices 26. Database Portability Considerations Expand section "26. Database Portability Considerations" Collapse section "26. Database Portability Considerations" 26.1. Portability Basics 26.2. Dialect 26.3. Dialect resolution 26.4. Identifier generation 26.5. Database functions A. Revision History Legal Notice Settings Close Language: 日本語 English Language: 日本語 English Format: Multi-page Single-page PDF Format: Multi-page Single-page PDF Language and Page Formatting Options Language: 日本語 English Language: 日本語 English Format: Multi-page Single-page PDF Format: Multi-page Single-page PDF Red Hat Training A Red Hat training course is available for Red Hat JBoss Web Server Appendix A. Revision History Revision HistoryRevision 1.0.2-1.1Wed Feb 11 2015Lucas Costi Updated the Product Name to reflect the new name grouping for the product. No update was made to details in the guide. Revision 1.0.2-1Tue Jun 21 2011Rebecca Newton Final build for EWS 1.0.2.GA. Previous Next