Hi , this is how I make use of collection filter :
Code:
ClassA classA = (ClassA) session.load(ClassA.class , key);
System.out.println("Original ClassBSet size = " + classA.getClassBSet().size());
Collection c = session.filter(classA.getClassBSet(),"where ...");
classA.setClassBSet(new TreeSet(c));
System.out.println("After filtering, ClassBSet size = " + classA.getClassBSet().size());
It really filters out what I want , but ...I have one question .
In the first println() , hibernate still gets all ClassB's instances ,
meaning that upon session.load(ClassA,class , key) , hibernate still loads all ClassB.
I am afread that if there are a lot of ClassB , it will out of memory...
Is it possible to set filter before load ClassA ?