-->
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.  [ 1 post ] 
Author Message
 Post subject: Init. a Collection with a sub set of data using a filter?
PostPosted: Tue Jul 20, 2004 2:02 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I currently have the requirement to lazy load a collection based on some date criteria.

i.e. I may have a collection of details that are amount sensitive and I want to be able to load up a sub set of that collection (ones that are above a certain amount).

I can use a filter such in the manner of
Code:
session.filter(persistentCollection, "where this.amt >= ?", new Object[]{new BigDecimal(160)}, new Type[]{Hibernate.BIG_DECIMAL});


This is all fine and dandy in the case that I can retrieve an ArrayList of elements that represent these records.

But what I really want to do is that I have a bidirectional association (consisting of a Set) that I want to lazy load at some point after my object is originally loaded (via LOCKing it back to a Session). During this I want to have my collection initialized with the sub set of my data.

With the sub set I want to be able to add, update, delete and only have the records within this sub set affected (via cascading from my parent object).

Is this even possible? I've been playing around with taking the returned collection and then constructing a new Set passing in the results from the session.filter call and setting that back on my parent object.

I've had some mixed success with this so far, i.e. if I am only updating the records it all seems fine. Adding a record seems that it would work as well. I'm having some issues with removing an existing record but that might be related to the fact that it can't seem to find my object in the HashSet. Even if it does manage to work I am terrified that it will create random havoc somewhere down the line.

I guess in the end of it all would be, is there an existing pattern for what I am attemping to accomplish.


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.