Hi
I "have" two classes:
Code:
class A {
B b; // can be null
Boolean gender;
}
class B extends Person { // Person contains firstName, lastName ...
String name;
}
c = session.createCriteria(A.class)
Criteria bc = c.createCriteria("b"); // Adding this forces B to be not null and the search will exclude A's that have a B that is null. How can I overcome this, I want to be able to search on b's properties and its superclasses ?
c.list();
"Solution" 1:add an OR for isNull and isNotNull on bc. However, I also want the user to be able to specify just one of the two. I could propably do that first, however that is an ugly solution.
"Solution" 2: Do not createCriteria or createAlias, but use dotted syntax b.name when you add restrictions. Sure that works, however when searching on the superclass Person, that wont work and will require createCriteria or createAlias.
Is there a way to create a sub accosiation notation that do not force the association to be not null.
// Thanks Hamidam