File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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 ?
It's not a secret anymore!