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