-->
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.  [ 4 posts ] 
Author Message
 Post subject: Initializing collections...
PostPosted: Thu Jul 21, 2005 3:09 am 
Newbie

Joined: Thu Jul 21, 2005 3:02 am
Posts: 11
Hi
Im quite new to Hibernate and seems to be missing something.
I have read the FAQ and searched the web for an answer - but with no luck.


Say I would like to initialize an object ObjA which has as a member collection "CollectionB" which can be reached by ObjA.CollectionB.

At some points I want that CollectionB contains elements where Year>2003 and sometimes I want CollectionB to contain objects where Year<2003. Is there some way that I can initialize CollectionB so that it will only contain the wanted elements.

My problem is that I have to hand over ObjectA (initialized with the correct version of CollectionB) to a business function that cannot work with a detached collectionB??

How can this be done????

Regards Morten


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 3:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, you could do it with a filter. But by the way you are stating the problem, I think you should simply write queries to do this.


Top
 Profile  
 
 Post subject: Collection does not get intialised after CreateFilter??
PostPosted: Thu Jul 21, 2005 5:10 pm 
Newbie

Joined: Thu Jul 21, 2005 3:02 am
Posts: 11
I use
Session.CreateFilter(ObjA.CollectionB,"where Year>2003).List();

But afterwards ObjA.CollectionB STILL got its origonal collection ie. it is not the new collection with fewer items in it??????

What am I doing wrong..

Can I just replace ObjA.CollectionB with the IList returned from the CreateFilter method or will this have some side effects??

Regards Morten


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 9:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I mean a Hibernate3 Filter, not a collection filter.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.