-->
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.  [ 5 posts ] 
Author Message
 Post subject: .:: Saving collections???
PostPosted: Fri Mar 05, 2004 11:31 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
Hi all!!!
I'm having some trouble while trying to save collections.
Here is my mapping document:
Code:
<class name="HotelRoom">
   <id name="code" type="long" column="code" unsaved-value="null">
      <generator class="native" />
    </id>
    <property name="ord" type="long"/>
    <property name="name" type="string" length="60"/>
    <property name="ident" type="string" length="20"/>
    <property name="description" type="string" length="60"/>
    <many-to-one name="hotel" column="hotel" unique="false"/>
    <property name="minAdults" type="int"/>
    <property name="maxAdults" type="int"/>
    <set name="childrensDisscount" inverse="true" lazy="true" order-by="hotelRoom" cascade="all">
       <key>
          <column name="hotelRoom"/>
          <column name="numAdults"/>
          <column name="numChildren"/>
       </key>
        <one-to-many class="HotelRoomWithChildrenDisscount"/>
    </set>
</class>

<class name="HotelRoomWithChildrenDisscount">
   <composite-id>
      <key-many-to-one name="hotelRoom" class="es.parsec.parsys.hotel.HotelRoom" column="hotelRoom"/>
      <key-property name="numAdults" type="int"/>
      <key-property name="numChildren" type="int"/>
   </composite-id>
</class>


And these are my classes:

Code:
public class HotelRoom
{
   private Long code;
   private long ord;
   private String name;
   private String ident;
   private String description;
   private Hotel hotel;
   private int minAdults;
   private int maxAdults;
   
   private Set childrensDisscount;
/** Getters and setters.......

public HotelRoomWithChildrenDisscount addNewHotelRoomWithChildrenDisscount()
   {
      HotelRoomWithChildrenDisscount hRoomWithChDisscount = new HotelRoomWithChildrenDisscount();
      hRoomWithChDisscount.setHotelRoom(this);
      
      getChildrensDisscount().add(hRoomWithChDisscount);
      
      return hRoomWithChDisscount;
   }
}

public class HotelRoomWithChildrenDisscount  implements Serializable
{
   
   private HotelRoom hotelRoom;
   private Integer numAdults;
   private Integer numChildren;

/** Getters and setters.......

}




And this is the code where I try to save the room with it


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 11:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
<property name="minAdults" type="int"/> is duplicated

And should be
<composite-id>
<key-many-to-one name="hotelRoom" class="es.parsec.parsys.hotel.HotelRoom">
<column column="hotelRoom"/>
<column name="numAdults"/>
<columnname="numChildren"/>
</key-many-to-one>
</composite-id>

The composite FK must be of the same size, format that the composite PK

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 11:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Oh, and read the doc again :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 5:48 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
thank you very much for your response, but I don't see where do I have duplicated
Code:
<property name="minAdults" type="int"/>
.
Thanks again ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 8:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've read to fast (min, max)

_________________
Emmanuel


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