Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lazy-loading of collections generated by HQL ?

 
Catalin Mihalache
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic