To store objects in a database, JPOX persistence module was added. Now persistent classes (all but Cart.java) will be declared in package.jdo file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC
"-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
"jdo.dtd">
<jdo>
<package name="example.bookshop.domain">
<class name="Author" detachable="true"></class>
<class name="Book" detachable="true" persistence-capable-superclass="Product">
<field name="author" default-fetch-group="true"/>
</class>
<class name="Magazine" detachable="true" persistence-capable-superclass="Product">
</class>
<class name="Order" detachable="true">
<field name="products" default-fetch-group="true"/>
</class>
<class name="Product" detachable="true"></class>
</package>
</jdo>
Notice how Java inheritance is indicated for classes Product, Book and Magazine. Also, notice how associations are defined for classes Book and Order. For example, by including <field name="author" default-fetch-group="true"/> in the Book class, JPOX is told to fetch the associated author everytime a Book object is fetched from database.
0 Ficheros adjuntos