Greetings,
I have a question on how I can construct a HQL query to search for an item. I have 2 main classes of interest. The SubscriptionInfo class contains a list of SubscriptionStatus objects. In these objects I have a reference to the subscription and the sequence number (the latest issue that the user has obtained).
What I want to do is find a SubscriptionStatus for the user X where the subscription is Y. I cant figure out how to build a HQL to do that.
For your reference, the mapping is provided here.
Thanks in advance.
-- Robert
Hibernate version:
Current production (NOT the beta)
Mapping documents:
Code:
<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping schema="CandiedServices"
package="com.bmw.candy.candiedServices.data">
<class name="Subscription" table="SUBSCRIPTION">
<id name="ID" type="long" unsaved-value="null" column="ID">
<generator class="native" />
</id>
<property name="name" length="16" not-null="true" />
<property name="description" length="256" not-null="true" />
<property name="sequenceNum" />
<list name="items" table="SUBSCRIPTION_ITEMS" lazy="true">
<key column="_itemID" />
<index column="_position"/>
<element type="string" length="1024" not-null="true" />
</list>
</class>
<class name="SubscriberInfo" table="SUBSCRIBER_INFO" lazy="true">
<id name="ID" type="long" unsaved-value="null" column="ID">
<generator class="native" />
</id>
<property name="username" length="15" not-null="true" />
<property name="password" length="30" not-null="true" />
<property name="familyName" length="30" not-null="true" />
<property name="givenName" length="30" not-null="true" />
<set name="subscriptions" table="SUBSCRIBER_SUBSCRIPTIONS">
<key column="_statusID" />
<composite-element class="SubscriptionStatus">
<property name="lastSequenceNumber" />
<many-to-one name="subscription"/>
</composite-element>
</set>
</class>
</hibernate-mapping>