This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths 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 Head First Android 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

how to set fetch type at runtime ? + Hibernate

Jigar Naik
Ranch Hand

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

Jigar Naik

Paul Sturrock

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

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 > :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:
subject: how to set fetch type at runtime ? + Hibernate
It's not a secret anymore!