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
|