-->
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: Criteria using a many-to-many - map relation
PostPosted: Wed Jan 17, 2007 12:12 pm 
Newbie

Joined: Sun Dec 10, 2006 3:40 am
Posts: 4
Hi There
I would like to know if Criteria objects can operate on collection of type Map

using hibernate 3.2

i have the following relation
table a - mapped with many-to-many to table b.
the lookup table C in the middle contains some more columns

this is the mapping

Code:
<hibernate-mapping package="test"
   default-lazy="false">
   <class name="A" table="A">
      <cache usage="read-write" />
      <id name="id" column="ID">
         <generator class="sequence">
            <param name="sequence">SEQ_A</param>
         </generator>
      </id>
      <map name="mapProp" table="C" cascade="save-update">
             <key column="ID_A"/>
             <map-key-many-to-many class="B" column="ID_B"/>
             <composite-element class="MapProp">
                <property name="propA" column="PROP_A"/>          
                <property name="propB" column="PROP_B"/>
             </composite-element>
          </map>       
   </class>
</hibernate-mapping>

<hibernate-mapping package="test"
   default-lazy="false">
   <class name="B" table="B">
      <cache usage="read-write" />
      <id name="id" column="ID">
         <generator class="sequence">
            <param name="sequence">SEQ_B</param>
         </generator>
      </id>
      <set name="A" inverse="true" cascade="none"
         table="C" lazy="true">
         <key column="ID_B" />
         <many-to-many class="A" column="ID_A" />
      </set>

   </class>
</hibernate-mapping>


I wish to execute the following statement using a criteria:
select ID from A where ID in (select ID_A from C where PROP_A = myInput)
the criteria might have restrictions relevant to table A only
that is the criteria is created the following way (up to now)
Code:
session.createCriteria(A.class);


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.