-->
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.  [ 3 posts ] 
Author Message
 Post subject: Exception when tryinh to save data
PostPosted: Mon Dec 29, 2003 2:31 pm 
Newbie

Joined: Fri Dec 05, 2003 11:07 am
Posts: 14
I am getting the following exception when trying to save records in a table using a loop.

Error 500: a different object with the same identifier value was already associated with the session:


heres the java code
for (int n=0; n < records; n++){
BOLDetails bd = new BOLDetails();
bd.setRowID(System.currentTimeMillis());
bd.setBolNumber((String)request.getParameter("BOLNum"));
bd.setOrderNum((String)request.getParameter("orderNum" + n));
bd.setSku((String)request.getParameter("sku" + n ));
bd.setShipQuan((String) request.getParameter("toship" + n ) );
ses.save(bd);
}

heres the XML
<class name="shipping.BOL.BOLDetails" table="MTBOLDetails">
<id name="rowID" type="string" unsaved-value="null" >
<column name="RowID" sql-type="char(50)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="bolNumber">
<column name="BOLnum" sql-type="char(20)" not-null="true"/>
</property>
<property name="orderNum">
<column name="OrderNum" sql-type="char(20)" not-null="true"/>
</property>
<property name="sku">
<column name="SKU" sql-type="varchar(25)" not-null="true"/>
</property>
<property name="shipQuan">
<column name="ShipQuantity" sql-type="int" not-null="true"/>
</property>
</class>

any help would be appreciated. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 2:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably you are doing just that: The Object generated in the second iteration has the same id as your previous object. I would strongly suggest to use another way to generate your keys the best way is to let Hibernate generate your keys, if you want to keep it simple, use generator class="increment"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 3:01 pm 
Newbie

Joined: Fri Dec 05, 2003 11:07 am
Posts: 14
thanks


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