Hibernate version: 3.0rc1
I read in the documentation (sections 9.1.6/9.1.7) that, using implicit
polymorphism it is possible to query using some base interface and
essentially get all classes which implement the interface and match
the query.
Well, I'm trying to use HQL to perform this (see code snippet below):
Code:
... java classes ...
public inteface BaseI {}
public class BaseClass { int prop1;}
public class Class1 extends BaseClass implements BaseI { int prop2;}
public class Class2 extends BaseClass { string propS;}
The hibernate mapping includes mappings for the actual classes BaseClass, Class1 and Class2. Next comes the query definition and
it goes something like this:
Code:
<query name="someQ">
<![CDATA[
select b
from BaseI as b
where b.class like ':className'
and b. prop1 = 10 ]]>
</query>
The intent is to get those objects implementing BaseI without regard to
the actual class (in this case instances of Class1), which I thought
was what the document was referring to.
However, I get an error when starting up the application, which states that BaseI
is not mapped, which is correct, but I thought that it would not need to be
mapped as a persistent class, rather that the mapping information will
capture this and will allow Hibernate to convert the query to whatever
multiple SQL queries are required to obtain the objects.
Anybody knows whether this is possible, or am I completely misreading the
document and I need to reorganise the mapping document/class hierarchy?