File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

Lazy-loading of collections generated by HQL ?

Catalin Mihalache

Joined: Aug 13, 2006
Posts: 6

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 ";
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.


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

Joined: Feb 05, 2001
Posts: 17276

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


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Lazy-loading of collections generated by HQL ?
It's not a secret anymore!