Kodo™ 4.1.4 Developers Guide for JPA/JDO Copyright © 2001 - 2006 BEA Systems Inc
Total Page:16
File Type:pdf, Size:1020Kb
Kodo™ 4.1.4 Developers Guide for JPA/JDO Copyright © 2001 - 2006 BEA Systems Inc. Kodo™ 4.1.4 Developers Guide for JPA/JDO Copyright © 2001 - 2006 BEA Systems Inc. Table of Contents 1. Introduction ............................................................................................................................................. 1 1. Kodo JPA/JDO ................................................................................................................................. 3 1.1. OpenJPA .............................................................................................................................. 3 1.2. About This Document ............................................................................................................. 3 1.2.1. Sales Inquiries ............................................................................................................. 3 2. Kodo Installation .............................................................................................................................. 4 2.1. Overview .............................................................................................................................. 4 2.2. Updates ................................................................................................................................ 4 2.3. Key Files in the Download ....................................................................................................... 4 2.4. Quick Start ............................................................................................................................ 4 2.5. Upgrading from Previous Kodo Versions .................................................................................... 4 2.6. Requirements ........................................................................................................................ 4 2.7. Terminology ......................................................................................................................... 5 2.8. Windows Installation .............................................................................................................. 5 2.9. POSIX (Linux, Solaris, Mac OS X, Windows with cygwin, etc.) Installation ..................................... 5 2.10. Common Installation Problems ............................................................................................... 6 2.11. Resources ........................................................................................................................... 6 2.12. Sales Inquiries ..................................................................................................................... 6 2. Java Persistence API ................................................................................................................................. 7 1. Introduction ....................................................................................................................................12 1.1. Intended Audience .................................................................................................................12 1.2. Lightweight Persistence ..........................................................................................................12 2. Why JPA? ......................................................................................................................................13 3. EJB Persistence Architecture .............................................................................................................15 3.1. EJB Exceptions .....................................................................................................................16 4. Entity ............................................................................................................................................18 4.1. Restrictions on Persistent Classes .............................................................................................19 4.1.1. Default or No-Arg Constructor ......................................................................................19 4.1.2. Final ........................................................................................................................19 4.1.3. Identity Fields ............................................................................................................19 4.1.4. Version Field .............................................................................................................19 4.1.5. Inheritance ................................................................................................................20 4.1.6. Persistent Fields .........................................................................................................20 4.1.7. Conclusions ...............................................................................................................21 4.2. Entity Identity ......................................................................................................................21 4.2.1. Identity Class .............................................................................................................22 4.2.1.1. Identity Hierarchies ..........................................................................................23 4.3. Lifecycle Callbacks ...............................................................................................................24 4.3.1. Callback Methods .......................................................................................................24 4.3.2. Using Callback Methods ..............................................................................................25 4.3.3. Using Entity Listeners .................................................................................................26 4.3.4. Entity Listeners Hierarchy ............................................................................................26 4.4. Conclusions .........................................................................................................................27 5. Metadata ........................................................................................................................................28 5.1. Class Metadata .....................................................................................................................29 5.1.1. Entity .......................................................................................................................29 5.1.2. Id Class .....................................................................................................................30 5.1.3. Mapped Superclass .....................................................................................................30 5.1.4. Embeddable ...............................................................................................................30 5.1.5. EntityListeners ...........................................................................................................31 5.1.6. Example ...................................................................................................................31 5.2. Field and Property Metadata ....................................................................................................33 5.2.1. Transient ...................................................................................................................34 iv Kodo™ 4.1.4 Developers Guide for JPA/JDO 5.2.2. Id .............................................................................................................................34 5.2.3. Generated Value .........................................................................................................34 5.2.4. Embedded Id .............................................................................................................35 5.2.5. Version .....................................................................................................................35 5.2.6. Basic ........................................................................................................................35 5.2.6.1. Fetch Type ......................................................................................................36 5.2.7. Embedded .................................................................................................................36 5.2.8. Many-To-One ............................................................................................................36 5.2.8.1. Cascade Type ..................................................................................................37 5.2.9. One-To-Many ............................................................................................................38 5.2.9.1. Bidirectional Relations ......................................................................................39 5.2.10. One-To-One .............................................................................................................39 5.2.11. Many-To-Many ........................................................................................................40 5.2.12. Order By .................................................................................................................40 5.2.13. Map Key .................................................................................................................41 5.2.14. Persistent Field Defaults .............................................................................................41