-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Expression.eq not working with many-to-one
PostPosted: Wed Apr 06, 2005 9:06 am 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
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


Top
 Profile  
 
 Post subject: Any ideas?
PostPosted: Thu Apr 07, 2005 2:20 pm 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
Does anybody have any ideas as to what I need to do? Or, can I provide any more information? I would have provided debug info but there wasn't any after the session was retrieved from the session factory to the time the exception was thrown. Thanks in advance.

Joe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.