Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.8
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.myadbox.bo">
<class name="MessageBox" table="message_box" dynamic-update="true">
<cache usage="read-write"/>
<id
name="Id"
type="java.lang.Long"
column="message_box_id"
>
<generator class="identity"/>
</id>
<!-- snip -->
<many-to-one
name="Owner"
class="MessageBoxOwner"
not-null="false"
>
<column name="message_box_owner_id"/>
</many-to-one>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.myadbox.bo">
<joined-subclass name="MessageBoxOwner"
table="message_box_owner"
extends="com.myadbox.bo.User">
<key column="message_box_owner_id" />
<!-- snip -->
</joined-subclass>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.myadbox.bo">
<class name="User" table="df_user">
<cache usage="read-write"/>
<id
column="user_id"
name="Id"
type="java.lang.Long"
>
<generator class="identity" />
</id>
<!-- snip -->
<property
column="first_name"
length="50"
name="FirstName"
not-null="false"
type="string"
/>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Criteria crit = getSession().createCriteria(MessageBox.class);
if (null != ownerFirstName) crit.add(Expression.eq("Owner.FirstName", "test").ignoreCase());
List list = crit.list();
Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: could not resolve property: Owner.FirstName of: com.myadbox.bo.MessageBox
at net.sf.hibernate.persister.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:50)
at net.sf.hibernate.expression.AbstractCriterion.getColumns(AbstractCriterion.java:42)
at net.sf.hibernate.expression.SimpleExpression.toSqlString(SimpleExpression.java:40)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:64)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3642)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
Name and version of the database you are using:
MySQL 4.1.9