-->
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.  [ 2 posts ] 
Author Message
 Post subject: only the 1st row of the n-side is inserted in the db
PostPosted: Wed Sep 10, 2003 11:54 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi all,

I have the following xml files:

<hibernate-mapping>

<class name="com.diatem.src.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="0">
<generator class="sequence"/>
</id>
<property name="name" column="team_name" type="string" length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>

<set name="players" cascade="all" inverse="false" lazy="true">
<key column="team_id"/>
<one-to-many class="com.diatem.src.Player"/>
</set>
</class>

</hibernate-mapping>

and

<hibernate-mapping>

<class name="com.diatem.src.Player" table="players">
<id name="id" column="player_id" type="long" unsaved-value="0">
<generator class="sequence"/>
</id>
<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>

<!--
<many-to-one name="team" class="com.diatem.src.Team" column="team_id"/>
-->

</class>

</hibernate-mapping>

when i try to save the Team object, only the first object from the players HashSet is inserted.
The Java sources I generate with Hibernate CodeGenerator.

Please help.

Thanks very much.

--steve


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think the codegenerator uses an equals() method which compares ids. So if you add multiple objects to a Set before saving them, only one will "stay there" .


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