I'm using Hibernate 3.1.3
This is a simple class model
public abstract Cat {
private String name;
private int age;
public abstract boolean processAge();
// setter and getter methods
........
}
public BigCat{
public boolean processAge(){
...........
}
}
public LittleCat{
public boolean processAge(){
...........
}
}
(In real enviroment I have about ten subclass)
and a mapping like:
<hibernate-mapping>
<class name="Cat" table="CATS">
<id name="catId" type="long" column="CAT_ID">
<generator class="native"/>
</id>
<discriminator column="internalDiscriminator" type="string"/>
<property name="name"/>
<property name="age"/>
<subclass name="BigCat"/>
<subclass name="LittleCat"/>
</class>
</hibernate-mapping>
It works, but if I try a java statement
List result = getSession().createQuery("BigCat").list();
Hibernate process two select from the table CATS, one for each subclass with internalDiscriminator='BigCat' and internalDiscriminator='LittleCat'.
I find this inefficient and unjustified, how can I perform only one select?
|