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: Problema with SaveOrUpdate and List
PostPosted: Sun May 02, 2010 1:17 pm 
Newbie

Joined: Sun May 02, 2010 1:07 pm
Posts: 2
Hi,

I've a object with a list:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="DataModel"
namespace="DataModel.Model">
<class name="Master">
<id name="Code" >
<generator class="assigned" />
</id>
<property name="Quantity" />

<bag name ="ExternalJobs" cascade="all-delete-orphan" table="ExternalJobs" lazy="true" >
<key column="Code" />
<one-to-many class="ExternalJob" />
</bag>
</class>
</hibernate-mapping>



<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="DataModel"
namespace="DataModel.Model">
<class name="ExternalJob">
<id name="Row" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="Operation" not-null="true"/>
<property name="Quantity" />

</class>
</hibernate-mapping>


In the class the bag is a IList.
When I populate the object and then I call SaveOrUpdate, the first time the object is save, the second time, the ExternalJob table have two row, the first is the first inserted with code set to null and the second is the new updated valued row.
Why is present this row with null value?

How to solve this problem?


Top
 Profile  
 
 Post subject: Re: Problema with SaveOrUpdate and List
PostPosted: Tue May 04, 2010 5:23 am 
Newbie

Joined: Sun May 02, 2010 1:07 pm
Posts: 2
I found error,

the problem was in setting row value.
When I update the value of the row was 0, and then a new row was created


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.