-->
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: Searching by assoication within a collection (HQL)
PostPosted: Wed Jul 28, 2004 1:25 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
Folks,

How could I refer to the code of UOMVO in HQL for my example at the bottom? (e.g. vo.quantityAllocations.quantity.UOMVO.code)


Code:
<!--
HQL
-->
select vo.code from BinSVO vo where 'Each' in elements(vo.quantityAllocations.quantity.UOMVO.code)
<!--
Exception
-->
net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: quantity [select vo.code from com.cendec.ikermit.materials.vo.BinSVO vo where 'Each' in elements(vo.quantityAllocations.quantity.UOMVO.code)

<!--
HQL
-->
select vo.code from BinSVO vo where 'Each' in elements(vo.quantityAllocations)
<!--
Generated SQL
-->
SELECT binsvo0_.code AS x0_0_
  FROM bin binsvo0_
WHERE ('Each' IN (
          SELECT quantityal1_.accountobjid, quantityal1_.afeobjid,
                 quantityal1_.companyobjid, quantityal1_.facilityobjid,
                 quantityal1_.featureobjid, quantityal1_.costamount,
                 quantityal1_.costcurrency_gnluobjid,
                 quantityal1_.quantityamount,
                 quantityal1_.quantityuom_gnluobjid,
                 quantityal1_.quantityjoint
            FROM bin_quantityallocation quantityal1_
           WHERE binsvo0_.objid = quantityal1_.binobjid)
       )

<!--
hbm file of BinSVO
-->
    <!-- Quantity Allocation for the Bin -->
    <bag name="quantityAllocations" cascade="all" table="bin_quantityallocation" lazy="false">
      <key column="BINOBJID"/>
      <composite-element class="QuantityAllocation">
        <nested-composite-element class="AccountString" name="accountString">
          <many-to-one name="accountCode" column="accountobjid" class="AccountVO"/>
          <many-to-one name="afeCode" column="afeobjid" class="AFEVO"/>
          <many-to-one name="companyCode" column="companyobjid" class="CompanyVO"/>
          <many-to-one name="facilityCode" column="facilityobjid" class="FacilityVO"/>
          <many-to-one name="featureCode" column="featureobjid" class="FeatureVO"/>
        </nested-composite-element>
        <nested-composite-element class="Cost" name="cost">
          <property name="amount" column="costamount" type="double"/>
          <many-to-one name="currency" column="costcurrency_gnluobjid" class="CurrencyVO"/>
        </nested-composite-element>
        <nested-composite-element class="Quantity" name="quantity">
          <property name="amount" column="quantityamount" type="double"/>
          <many-to-one name="UOMVO" column="quantityuom_gnluobjid" class="UOMVO"/>
          <property name="joint" column="quantityjoint" type="long"/>
        </nested-composite-element>
      </composite-element>
    </bag>


Thanks in advance!

Martin
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 12:05 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
<!--
Update
-->
I know I could use join, but I'm just wondering if I could use the dot notation to access the assoication within the collection or not?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 8:11 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
OK, I found this "Implicit joins are always directed along mant-to-one or one-to-one associations; never thourgh a collection valued association (you can't write item.bids.amount)", so I have to use explicit joins then!


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.