-->
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.  [ 4 posts ] 
Author Message
 Post subject: Criteria - Multiple object
PostPosted: Fri Sep 30, 2005 9:46 am 
Newbie

Joined: Wed Aug 10, 2005 8:07 am
Posts: 14
Hibernate version:3.0.5

IS it possible to retrieve multiple objects per row with Criteria Query ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 2:46 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
When you say multiple objects what do you mean? For example there is

Criteria.list();

that returns all the results matching the criteria, but would all be of the same class, or do you mean many object corresponding to different classes?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:15 pm 
Newbie

Joined: Wed Aug 10, 2005 8:07 am
Posts: 14
I mean many object corresponding to different classes
E.Q Object Account and Bank which are associated !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:31 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
If you are doing a query on bank accounts and how they relate to a bank, then you will want to have a many-to-one association in your mapping file.

As an example, here is a snippet for one that I have done, where many reservations are associated with one guest:

Code:

<hibernate-mapping>
   <class name="domain.Reservation" table="reservations">

      <id
         name="key"
         column="id"
         type="integer">
         <generator class="native"/>
      </id>      

      <property
         name="date"
         column="resDate"
         type="date"/>

      <property
         name="time"
         column="resTime"
         type="time"/>      

<!-- guest corresponds to the attribute 'guest' in my reservation class,
       while guestId is the reference made to the Guest, from this entry.
-->
      <many-to-one             
           name="guest"
           column="guestId"
           class="domain.Guest"
           fetch="join"
           lazy="false"/>
           
   </class>
</hibernate-mapping>


Hope this helps.


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