-->
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: Filtering Collections
PostPosted: Fri Jun 10, 2005 7:13 am 
Newbie

Joined: Fri Jun 10, 2005 7:00 am
Posts: 2
Hibernate version: 3.0.3

Hello,

I have read about the new filter-def in Hibernate 3.0, but I think it is not versatile enough for my application. Is there another way to filter the associated collections of an object?

The associated Objects to my "main"-object are being versioned, so their amount can grow without limit. I'd like to just retrieve the ones with current version (for example).

I can of course return an array [mainObject, filteredAssociatedObjects[]], but if I could just retrieve the filtered collection with mainObject.getAssociatedObjects(), it would of course be much nicer. (I can't use session in outer view, as view and persistence layer are on different servers).

My understanding of the filter-def is that this would happen if I could formulate the appropiate query in the mapping file. But I can't (need joins, besides, it's not pretty to go down to SQL level).

I don't think the session.createFilter(mainObject.getAssociatedObjects(),"blaql") would have the same effect? I am using it now to retrieve the filteredAssociatedObjects[] to build my array, although I don't really see an advantage over using a normal Query.

But if no way to do it exists yet, it seems it might be nice to just add a Query.setFilter() method that accepts full HQL?

Although I must admit it seems straightforward for "read access", but I am not sure if the semantics for writing would also be sraightforward. Ie what would happen id one adds an object to a filteredAssociatedObjects collection? But maybe it is not a problem, not sure...

Anyways, I would be thankful for any better ideas to handling the collection filtering nicely.


Bjoern


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