-->
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: Urgent help needed searching in component object
PostPosted: Tue Jan 25, 2005 2:22 pm 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
Sorry about the double post .. the other post I messed up ... lets fix it here...



I am trying to use a query to search in a collection that is stored as a
component object and I am getting quite stuck. Here is the HQL:

Code:
select status.lastIssue from Subscriber subscriber
join subscriber.subscriptions as status
where subscriber.ID = :subscriberID
and status.subscription.ID = :subscriptionID


And here is the actual method that I am trying ot execute:

Code:
    public void updateSubscriptionStatus(final long subscriberID, final long subscriptionID,
                                    final int issueNumber) throws CandiedServicesException {
        final String FIND_STATUS = "select status from Subscriber subscriber" //$NON-NLS-1$
                                   + " join subscriber.subscriptions as status" //$NON-NLS-1$
                                   + " where subscriber.ID = :subscriberID" //$NON-NLS-1$
                                   + " and status.subscription.ID = :subscriptionID"; //$NON-NLS-1$

        try {
            final Session session = HibernateUtil.fetchThreadSession();
            final Transaction tx = session.beginTransaction();

            final Query query = session.createQuery(FIND_STATUS);
            query.setLong("subscriberID", subscriberID); //$NON-NLS-1$
            query.setLong("subscriptionID", subscriptionID); //$NON-NLS-1$
            final SubscriptionStatus status = (SubscriptionStatus) DataUtils.fetchSingleObject(query);
            status.setLastIssue(issueNumber);

            tx.commit();
            HibernateUtil.closeThreadSession();
        } catch (final HibernateException ex) {
            throw new RuntimeException(ex);
        }
    }



This code is baffling me as it is returning the exception:

Code:
net.sf.hibernate.QueryException: could not resolve property: id of: com.bmw.candy.candiedServices.data.SubscriptionStatus [select status from com.bmw.candy.candiedServices.data.Subscriber subscriber join subscriber.subscriptions as status where subscriber.ID = :subscriberID and status.subscription.ID = :subscriptionID]


I would appreciate someone enlightening me on what I am doing wrong here. Thanks.

-- Robert

Hibernate version:
Stable - not alpha

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" unique="true"/>
      <property name="description" length="256" not-null="true" />
      <set name="issues" sort="natural" table="SUBSCRIPTION_ISSUES" access="field">
         <key column="_issueID" />
         <composite-element class="SubscriptionIssue">
            <property name="issueNumber" not-null="true"/>
            <property name="issueURL" length="512" not-null="true"/>
            <many-to-one name="subscription"/>
         </composite-element>
      </set>
   </class>

   <class name="Subscriber" table="SUBSCRIBER">
      <id name="ID" type="long" unsaved-value="null" column="ID">
         <generator class="native" />
      </id>
      <property name="username" length="15" not-null="true" unique="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" sort="natural" table="SUBSCRIBER_SUBSCRIPTIONS" access="field">
         <key column="_statusID" />
         <composite-element class="SubscriptionStatus">
            <property name="lastIssue" not-null="true"/>
            <many-to-one name="subscription" not-null="true"/>
            <many-to-one name="subscriber" not-null="true"/>
         </composite-element>
      </set>
   </class>

</hibernate-mapping>


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.