-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Criteria Query
PostPosted: Sun Nov 21, 2004 10:31 am 
Newbie

Joined: Sun Nov 21, 2004 10:08 am
Posts: 1
Hi,

In order to improve the performance, I would want to load only the required relations at the startup of the application..

But at the same time, I would set "lazy =true" to retrive the all related objects participating in the relationships.

Later, using Qurery Criteria, I would like to pick up the desired relation , even after the session is closed.

A detailed scenario is explained below:

There are employees, each employee belongs to a project, and each project has a customer. There are employee, project and customer master tables to store these data. Now, the many-to-one relations between employee and project as well as project and customer are defined and the project and the customer classes are declared as 'lazy = true'.

If I select the employee and close the session, then I would not be able to access the project or the customer since the session is not available. But if I create a criteria query and then explicitly ask these relations to be loaded, then they will be loaded when the first select is executed itself and hence they would be available even after the session is closed.


Has anyone have a similar requirement/ scenario ?

Any help in this regard would be greatly appreciated.

Thanks
Uthra


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 21, 2004 1:38 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Hello,

You can first retrieve the object without loading the lazy objects. You can initialize the lazy objects (with the session active) with Hibernate.initialize(LAZYOBJECT).
Then when the application is loaded you can reattach the object to a new Session with newSession.lock(obj,LockMode.NONE). Then you can retrieve the last lazy objects with Hibernate.initialize(obj.getCollection());

Hope this helps.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.