This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Lazy-loading of collections generated by HQL ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Lazy-loading of collections generated by HQL ?" Watch "Lazy-loading of collections generated by HQL ?" New topic
Author

Lazy-loading of collections generated by HQL ?

Catalin Mihalache
Greenhorn

Joined: Aug 13, 2006
Posts: 6
Hello.

Please, excuse my English.

I use Hibernate Core 3.2.1. All my entities and collections have lazy loading.

I have something like this:

String hql = "from WorkStage ws order by ws.no ";
Query query = session.createQuery(hql);
List listWorkStages = query.list();

Hibernate loads all records from table associated with WorkStage class.
What I want is to have lazy loading for this kind of list (listWorkStages).

Please, give me a hint.

Thanks,
Catalin.


SCJP 5.0 - 95%<br />SCWCD 1.4 - 88%
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

Catalin, you are querying that table and there is no where clause, so you get all the records back. It is the query, there is no "lazy loading" that can be done here.

You can instrument the code, a post compile stept o do, and the values inside the Object will be lazy loaded. That might be what you are looking for. And for instrumenting the code, you will need to go to hibernate's website to find out how in the documentation.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
jQuery in Action, 2nd edition
 
subject: Lazy-loading of collections generated by HQL ?