Suppose I have the following class relationship.
public class Plane
{
int wings; // number of wings.
// etc.
}
public class JetPlane
{
int numPilots;
String model;
// etc.
}
I now do this.
List results = session.createCriteria(Plane.class)
.add(Expression.eq("model", "AirBus");
I get this.
1) testPlanesByCriteria2(com.ap.ApTest)java.lang.NullPointerException
at net.sf.hibernate.persister.NormalizedEntityPersister.toColumns(NormalizedEntityPersister.java:1099)
at net.sf.hibernate.expression.AbstractCriterion.getColumns(AbstractCriterion.java:35)
at net.sf.hibernate.expression.SimpleExpression.toSqlString(SimpleExpression.java:40)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:66)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3591)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at com.ap.ApTest.testPlanesByCriteria2(ApTest.java:305)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at com.ap.ApTest.main(ApTest.java:29)
My mapping file looks like this.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="com.ap.Plane" table="planes" discriminator-value="N"
polymorphism="implicit">
<id name="id">
<generator class="native"/>
</id>
<property name="wings" column="`wings`" not-null="true"/>
<joined-subclass name="com.ap.JetPlane">
<key column="JetPlanes"/>
<property name="numPilots" column="`npilots`" not-null="true"/>
<property name="model" column="`model`" not-null="true"/>
</joined-subclass>
</class>
</hibernate-mapping>
Can somebody please tell me if Hibernate is supposed to be able to
handle this case? Yes, I know that 'model' is not a property of
'Plane'. I believe I understand some of the difficulties, however
the mapping file does contain global information about all subclasses
of Plane.
Many thanks,
--
Ravi/
|