Hi,
I read some place that hibernate filters are not supported for single relationships.
Im retrieving a large object graph, which is displayed in its completeness and actually has self referential relationships (i.e A person in Person is related to another person in the same Person table etc)
Since it is effectively recursive and arbitrarily deep, getting the graph in one hit using hibernate relationships is much better than recursively descending the tree myself getting child nodes, and child->child nodes etc.
This all works fine and hibernate appears to be able to detect potential loops in this too. So no problem there (I assume loops are avoided using the first level cache).
I now need to retrieve the graph (which has more than one table relation BTW, not just Person), but filtered on an effective date column which appears in all tables. (or nearly all tables).
Apart from the fact applying filters can cause second level cache issues for some reason, I now find I cant apply a filter to a many-to-one realtionship. I AM setting the filter on the child class itself of a many-to-one but it doesnt even appear in the generated SQL and I cant set a filter on the many-to-one association mapping.
So what if any, (assuming filters cannot be used in this case) would be the usual solution to such a problem that doesnt involve removing the hibernate mapping for the association and generating the HQL myself to retrieve only effective rows and setting them in the parent manually.
Last edited by tim.taylor on Fri Apr 03, 2009 6:30 am, edited 2 times in total.
|