Java Reference
In-Depth Information
H Maps
coupon field
<many-to-one name="Coupon"
class="AbstractCouponImpl"
column="COUPON_ID"/>
</class>
<hibernate-mapping>
Let's look at the details:
B
The <class> element specifies that the PendingOrder is mapped to the
PENDING_ORDER table.
C
D
E
The <id> element defines the primary key property and its column.
The deliveryDate and state fields are mapped to columns.
The mapping for the deliveryAddress field uses the <component> mapping. The
<property> elements nested within the <component> element map the fields of the
Address to columns of its PENDING_ORDER table. The mapping for the payment
information field is similar.
F
The PendingOrder - Restaurant relationship is mapped using a <many-to-one> ele-
ment.
G
The PendingOrder - PendingOrderLineItems relationship is mapped as a compo-
nent collection by using a <list> element that contains a <composite-element> , as
described in section 6.1.1.
The PendingOrder - Coupon relationship is mapped using a <many-to-one> element.
Note that the relationship mappings in this example use the default setting for
eager/lazy loading and so Hibernate will lazily load related classes such as Restau-
rant , Coupon , and PendingOrderLineItem . In section 6.5 you will see how to config-
ure eager loading to improve performance.
After adding the id field to the PendingOrder class and writing the O/R map-
ping document, we can now persist instances of the PendingOrder class and the
tests that we wrote earlier pass. Let's now see how to implement a repository class
using Hibernate.
H
 
 
 
Search WWH ::




Custom Search