
Hibernate Reference Documentation Version: 3.0 Table of Contents Preface ..........................................................................................................................................viii 1. Quickstart with Tomcat ..............................................................................................................1 1.1. Getting started with Hibernate ............................................................................................. 1 1.2. First persistent class ........................................................................................................... 3 1.3. Mapping the cat ................................................................................................................. 4 1.4. Playing with cats ................................................................................................................ 5 1.5. Finally ...............................................................................................................................7 2. Architecture ................................................................................................................................8 2.1. Overview ...........................................................................................................................8 2.2. Instance states .................................................................................................................. 10 2.3. JMX Integration ............................................................................................................... 10 2.4. JCA Support .................................................................................................................... 11 3. Configuration ............................................................................................................................ 12 3.1. Programmatic configuration .............................................................................................. 12 3.2. Obtaining a SessionFactory ............................................................................................... 12 3.3. JDBC connections ............................................................................................................ 13 3.4. Optional configuration properties ...................................................................................... 14 3.4.1. SQL Dialects ......................................................................................................... 19 3.4.2. Outer Join Fetching ............................................................................................... 20 3.4.3. Binary Streams ...................................................................................................... 20 3.4.4. Second-level and query cache ................................................................................. 20 3.4.5. Transaction strategy configuration .......................................................................... 20 3.4.6. JNDI-bound SessionFactory ................................................................................... 21 3.4.7. Query Language Substitution ................................................................................. 21 3.4.8. Hibernate statistics ................................................................................................ 22 3.5. Logging ........................................................................................................................... 22 3.6. Implementing a NamingStrategy ....................................................................................... 23 3.7. XML configuration file ..................................................................................................... 23 4. Persistent Classes ...................................................................................................................... 25 4.1. A simple POJO example ................................................................................................... 25 4.1.1. Declare accessors and mutators for persistent fields ................................................. 26 4.1.2. Implement a no-argument constructor ..................................................................... 26 4.1.3. Provide an identifier property (optional) .................................................................. 26 4.1.4. Prefer non-final classes (optional) ........................................................................... 27 4.2. Implementing inheritance ................................................................................................. 27 4.3. Implementing equals() and hashCode() .............................................................................. 27 4.4. Dynamic models .............................................................................................................. 28 5. Basic O/R Mapping ................................................................................................................... 30 5.1. Mapping declaration ......................................................................................................... 30 5.1.1. Doctype ................................................................................................................ 31 5.1.2. hibernate-mapping ................................................................................................. 31 5.1.3. class ..................................................................................................................... 32 5.1.4. id .......................................................................................................................... 34 5.1.4.1. Generator ................................................................................................... 35 5.1.4.2. Hi/lo algorithm ........................................................................................... 36 5.1.4.3. UUID algorithm ......................................................................................... 36 5.1.4.4. Identity columns and sequences ................................................................... 36 5.1.4.5. Assigned identifiers .................................................................................... 37 Hibernate 3.0 ii HIBERNATE - Relational Persistence for Idiomatic Java 5.1.4.6. Primary keys assigned by triggers ................................................................ 37 5.1.5. composite-id ......................................................................................................... 37 5.1.6. discriminator ......................................................................................................... 38 5.1.7. version (optional) .................................................................................................. 38 5.1.8. timestamp (optional) .............................................................................................. 39 5.1.9. property ................................................................................................................ 39 5.1.10. many-to-one ........................................................................................................ 41 5.1.11. one-to-one ........................................................................................................... 42 5.1.12. component, dynamic-component .......................................................................... 43 5.1.13. properties ............................................................................................................ 44 5.1.14. subclass .............................................................................................................. 45 5.1.15. joined-subclass .................................................................................................... 46 5.1.16. union-subclass ..................................................................................................... 47 5.1.17. join ..................................................................................................................... 47 5.1.18. key ..................................................................................................................... 48 5.1.19. column and formula elements ............................................................................... 49 5.1.20. import ................................................................................................................. 49 5.1.21. any ..................................................................................................................... 50 5.2. Hibernate Types ............................................................................................................... 50 5.2.1. Entities and values ................................................................................................. 51 5.2.2. Basic value types ................................................................................................... 51 5.2.3. Custom value types ............................................................................................... 52 5.3. SQL quoted identifiers ...................................................................................................... 53 5.4. Metadata alternatives ........................................................................................................ 53 5.4.1. Using XDoclet markup .......................................................................................... 53 5.4.2.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages193 Page
-
File Size-