-->
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.  [ 1 post ] 
Author Message
 Post subject: ** Query of composite element fields in HQL **
PostPosted: Tue Jun 21, 2005 5:31 am 
Newbie

Joined: Tue Jun 14, 2005 12:44 pm
Posts: 19
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:
<hibernate-mapping package="com.channels">
<class name="MessageDBObject" table="Messages" lazy="false">
<id name="messageId">
<column name="MessageId" length="36"/>
</id>
<property name="SessionId" length="36"/>
<list name="fields" table="MessageFields">
<key not-null="true">
<column name="MessageId" length="36"/>
</key>
<list-index column="FieldIndex" />
<composite-element class="MessageFieldDBObject">
<property name="FieldName"/>
<property name="FieldValue"/>
</composite-element>
</list>
</class>

</hibernate-mapping>

A Message contains a list of MessageFields.

I have a Message with MessageFields which are mapped to an object but do not have their own XML (IE not part of the mapping).

My question is this - how do I use HQL to query my messages for particular message fields (with a specified value)?
I cannot use the elements keywork because of the mapping problem (Hibernate throws a Mapping Exception and says it does not recognize the entity when I create a MessageField object).

I would like to iterate inside the HQL query to find out that my message
contains field with a particular name I pass as a parameter, and a LIKE query on the field value.

So far I have tried creating a mssageField object and query string:

select :field from elements(message.field)

and passing the field to the query. I have received mapping exceptions and even an SQL query exception after trying to map the MessageField object.

Could anyone write a simple query that does this for me? I am really struggling here.

Best regards
Eyal


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

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.