Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List query annotation ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Hibernate have a List annotation to load this List in the LAZY mode ? something like this



Thanks.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic