-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL works in 3.1 but not 3.2
PostPosted: Fri Apr 20, 2007 6:28 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Hi, could anyone tell me what's wrong with this query pls?

Code:
<query name="Offer.linkedConditions">
      <![CDATA[ from ConditionValue c where c.conditionId in (select o.conditions.conditionId from OfferValue o where o.offerId = :offerId) ]]>
</query>


It works in 3.1, but I upgraded to 3.2 to get an unrelated bug fix, and the HQL isn't valid any more. I used the new antlr 2.7.6 and tried both query parsers mentioned in the migration guide. I've tried lots of variations based on the docs but I can't get it to work in 3.2. BTW it's definately a problem with the subselect.

Here're the mappings:
Code:
<class name="com.lsb.uk.mqs.value.OfferValue" table="MORTGAGE_OFFER">
      <id name="offerId" column="OFFER_ID" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">OFFER_ID_SEQ</param>
         </generator>
      </id>
      <property name="applicationId" column="APPLICATION_ID"/>
      <property name="offerDate" column="OFFER_MADE_ON"/>
      <property name="buildingInsurance" column="BUILDINGS_INSURANCE" type="nullint"/>
      <property name="response" column="RESPONSE" type="nullint"/>
      <property name="responseDate" column="RESPONSE_DATE"/>
      <property name="revised" column="REVISED" type="nullboolean"/>
      <property name="revisedDate" column="REVISED_DATE"/>
      <property name="completed" column="COMPLETED" type="nullboolean"/>
      <property name="completedDate" column="COMPLETED_DATE"/>
      <property name="rejectedDate" column="REJECTED_DATE"/>
      <property name="lastUpdateDate" column="LAST_MODIFIED_ON"/>
      <property name="lastUpdateUser" column="LAST_MODIFIED_BY"/>

        <bag name="conditions" table="MORTGAGE_OFFER_CONDITION" lazy="true">
            <key column="OFFER_ID"/>
            <many-to-many class="com.lsb.uk.mqs.value.ConditionValue"
                          column="CONDITION_ID"/>
        </bag>
    </class>

   <class name="com.lsb.uk.mqs.value.ConditionValue" table="CONDITIONS">
      <id name="conditionId" column="ID" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">offer_conditions_seq</param>
         </generator>
      </id>
      <property name="condition" column="DESCRIPTION"/>
      <property name="country" column="COUNTRY"/>
      <property name="lastUpdateUser" column="LAST_MODIFIED_BY"/>
      <property name="lastUpdateDate" column="LAST_MODIFIED_ON"/>
   </class>


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 7:27 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This was and is an illegal path expression: o.conditions.conditionId

Use an explicit join. The only difference is that 3.1 did not complain and it worked by accident in some cases. It was never supported, in fact, the documentation always said "Don't do it".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 9:19 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Thanks Christian.

Did what you said and it works perfectly. For completeness, here's the changed query, which works in 3.2

Code:
<![CDATA[ from ConditionValue c where c.conditionId in (select c.conditionId from OfferValue o join o.conditions as c where o.offerId = :offerId) ]]>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.