This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes List query annotation ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "List query annotation ?" Watch "List query annotation ?" New topic

List query annotation ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Does Hibernate have a List annotation to load this List in the LAZY mode ? something like this

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

A one-to-many can be easily mapped by using your class associations themselves. Here's an example of a Team having many Players:

The FetchType attribute can be set to EAGER, or as you seem to prefer, LAZY.

Mapping Lazy One to Many Associations with JPA (Java Persistence API)

-Cameron McKenzie
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
The problem is Hibernate don't allow more than two EAGER at same time. Therefore most of time, we have to use LAZY. In the lazy mode, then we have to decide where to load the collection.

I agree. Here's the link:
subject: List query annotation ?