This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes how to set fetch type at runtime ? + Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to set fetch type at runtime ? + Hibernate" Watch "how to set fetch type at runtime ? + Hibernate" New topic
Author

how to set fetch type at runtime ? + Hibernate

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
How can we set the fetch type at runtime



Jigar Naik


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can specify it in your query.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1


Here's an example of fetching associated properties in an eagar manner at runtime. Without an HQL query, I don't believe there's anything you can do to dynamically change the FetchType that has been set in a mapping or through a Java Persistence API (JPA) annotation.


from Sale sale
where sale.date > :startDate
left join fetch sale.salesman
left join fetch sale.product
left join fetch sale.product.color
left join fetch sale.product.category


Setting FetchType to Eagar at Runtime with a Hibernate Query

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set fetch type at runtime ? + Hibernate
 
Similar Threads
how to display database values in a table
hibernate one to many reationship.
not able to retrive updated data from session using session.load + hibernate
Lazy Loading
db2 type 4 driver result set fetch size