It's not a secret anymore!
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
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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: 744
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: 4967


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


Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
 
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.
Lazy Loading
not able to retrive updated data from session using session.load + hibernate
db2 type 4 driver result set fetch size