-->
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: What is the HQL for accessing a one-to-many
PostPosted: Thu Jul 08, 2004 1:14 pm 
Beginner
Beginner

Joined: Wed Jun 23, 2004 12:37 pm
Posts: 20
Hi

Trying out my HQL against a one-to-many and not having much luck. I'm trying to select all the 'messages' for a given 'MessageStore'. The message has a FK column called inbox_id pointing back to the MessageStore table.

My Hib' querry is (which does work):
from net.simtext.server.core.domain.Message as message where message.id>? and message.inbox_id = ?

My SQL querry which does what I want would be:
SELECT * FROM `message` where inbox_id = ?;

The exception is:
net.sf.hibernate.QueryException: could not resolve property: inbox_id of: net.simtext.server.core.domain.Message [from net.simtext.server.core.domain.Message as message where message.id>? and message.inbox_id = ?]

My mapping is:
<hibernate-mapping>
<class name="MessageStore" table="message_store" >
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>

<list name="inboxMessages">
<key column="inbox_id" />
<index column="position"/>
<one-to-many class="Message" />
</list>
...

</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="Message" table="message" >
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>

<property name="text" type="string" length="320" >
<meta attribute="use-in-tostring">true</meta>
</property>

...

</class>
</hibernate-mapping>


Hib 2.1.4
MySQL 4.0.18

Hope you can help

Cheers

Nick


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 5:19 am 
Beginner
Beginner

Joined: Wed Jun 23, 2004 12:37 pm
Posts: 20
Sorry, that should read


My Hib' querry is (which does NOT work):
from net.simtext.server.core.domain.Message as message where message.id>? and message.inbox_id = ?


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.