Hibernate version: 3.1.rc2
Mapping documents:
Code:
<class name="Resurs" table="RESURS">
<id name="id">
<column name="RESURSID" sql-type="INTEGER"/>
<generator class="identity">
</generator>
</id>
<discriminator formula="(SELECT CASE WHEN t1.BETECKNING LIKE '%tarfil' THEN 'tarfil' ELSE t1.BETECKNING END FROM RESURSTYP t1 WHERE t1.RESURSTYPID = RESURSTYPID)"/>
<many-to-one name="typ" class="Resurstyp" lazy="false" foreign-key="FK_RESTYP_RES" index="RESURS_FK RESURS_SK">
<column name="RESURSTYPID" sql-type="INTEGER" not-null="true"/>
</many-to-one>
.....
</class>
<class name="Resurstyp" table="RESURSTYP">
<cache usage="read-only"/>
<id name="id">
<column name="RESURSTYPID" sql-type="INTEGER"/>
<generator class="identity">
</generator>
</id>
<property name="beteckning">
<column name="BETECKNING" length="50" not-null="true"/>
</property>
.....
</class>
Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = session.createCriteria(Resurs.class);
criteria.add(Expression.eq("typ.beteckning","whatever"));
return criteria.list();
Full stack trace of any exception that occurs:
could not resolve property: typ.beteckning of: matrix.v.dataaccess.pojo.Resurs
Question is why? This has to be the most basic type of Criteria. All I am doing is trying to query on the a foreign keyed type (i.e. resurstyp).