File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 17249
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Lazy-loading of collections generated by HQL ?
 
Similar Threads
Hibernate Newbie
please help me avoid n+1 select hibernate
i not wnat to lazy initialization
With JPA how can I force loading of nested lazy collections?
hibernate left join fetch question