Java Reference
In-Depth Information
Listing 10.5. Relationships in the Item entity
By default, some of the relationship types are retrieved lazily and some are loaded eagerly.
We'll discuss why each default makes sense as we go through each relationship retrieval
case for the Item entity. The Seller associated with an Item is retrieved eagerly, be-
cause the fetch mode for the @ManyToOne annotation is defaulted to EAGER . To under-
stand why this makes sense, it's helpful to understand how the EntityManager imple-
ments eager fetching. In effect, each eagerly fetched relationship turns into an addition-
al JOIN tacked onto the basic SELECT statement to retrieve the entity. To see what this
means, see how the SELECT statement for an eagerly fetched Seller record related to an
Item looks in the following listing.
Listing 10.6. SELECT statement for eagerly fetched Seller related to an Item
 
Search WWH ::




Custom Search