Hi Osian
I can see 2 possible answers for your question.
Answer 1
--------
Try to use filters.
Well, this solution is not based on annotation, but it is a regular Hibernate functionality. And, using filter, you can operate using property name, not database column name.
See:
http://docs.jboss.org/hibernate/stable/ ... -filteringSo, in this technique, you will still get getAllChildren() Hibernate mapping, but using filters, you will never load this collection into memory. So you can have millions of children per particular entity, but using filters, Hibernate will generate database hit, every time, you use filter.
Answer 2
--------
Did you try to map your Children types as separated children type using “Inheritance mapping”?
http://docs.jboss.org/hibernate/stable/ ... nheritanceI’ve got impression that you could consider map your children as different type, using “discriminator” Hibernate technique.
Well... Then, you can try to change your mapping and give a try to the following mapping:
Code:
class Children { ... }
class ChildrenOfType1 extends Children{ ... }
class ChildrenOfType2 extends Children{ ... }
List<ChildrenOfType1> getChildrenOfType1() { ... }
List<ChildrenOfType2> getChildrenOfType2() { ... }
I don’t know if it works. I didn’t try this trick.
Regards, Adam Woźniak