This is my hierarchy:
// Table a
class A {}
// Table(" b
class B extends A {}
// Table my_class
class MyClass {
A a;
}
I want to retrieve all MyClass objects from database with a relation to B but not to A.
B is a joined-subclass (extension of the table a by id).
My idea was something :
Criteria criteria = session.createCriteria(MyClass.class);
criteria.add(Restrictions.eq("a.class", B.class);
But it outputs an error:
could not resolve property: a.class of a.b.MyClass
This is the simplest way I could put it. Bear in mind that the query is a bit more complicated.
Regards.
Udo.
I usually write a DetachedCriteria which selects all B’s and filter MyClass where A in AllBs:
(There may be errors, I’m not a java programmer.)
Creates something like: