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