-->
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.  [ 4 posts ] 
Author Message
 Post subject: update transient object,is this a bug
PostPosted: Fri Jan 07, 2005 4:51 am 
Newbie

Joined: Wed Oct 13, 2004 11:54 pm
Posts: 6
2.1.4

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="gov.ijob.domain.po.talents">
<class name="TbTestPO" table="TBTEST" schema="ijob">
<id name="testId" column="TEST_ID" type="java.lang.String" >
<generator class="com.dsii.common.hibernate.CustomizedIdGenerator">
<param name="field_name">tbtest_pk</param>
<param name="rule">*yyyyMMdd,#s6</param>
</generator>
</id>

<timestamp name="modifyDate" column="MODIFY_DATE"/>
<property name="contents" column="CONTENTS" type="java.lang.String"/>

</class>
</hibernate-mapping>


Transaction tx=session.beginTransaction();
tbTestPO.setTestId("20050107000000");
tbTestPO.setContents("OOKK");
tbTestPO.setModifyDate(new Timestamp(System.currentTimeMillis()));
session.update(tbTestPO);
tx.commit();


net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for gov.ijob.domain.po.talents.TbTestPO instance with identifier: 20050107000000
at net.sf.hibernate.persister.AbstractEntityPersister.check(AbstractEntityPersister.java:501)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:672)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2368)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at gov.ijob.domain.bean.talents.test.ResumeBasicInfoBeanTest.testCreate(ResumeBasicInfoBeanTest.java:89)
at gov.ijob.domain.bean.talents.test.ResumeBasicInfoBeanTest.main(ResumeBasicInfoBeanTest.java:47)


oracle 9.2

update ijob.TBTEST set MODIFY_DATE=?, CONTENTS=? where TEST_ID=? and MODIFY_DATE=?

Debug level Hibernate log excerpt:

is it a bug?if i get rid of timestamp,i can work well


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 8:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
by the looks of your column name (MODIFY_DATE) it looks to me the column only store the DAY (not milliseconds)....that would make it only possible to update a row once a day - probably not what you want ;)

<timestamp> and <version> is for optimistic locking - not to track which day it was update.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 11:01 am 
Newbie

Joined: Wed Oct 13, 2004 11:54 pm
Posts: 6
max wrote:
by the looks of your column name (MODIFY_DATE) it looks to me the column only store the DAY (not milliseconds)....that would make it only possible to update a row once a day - probably not what you want ;)

<timestamp> and <version> is for optimistic locking - not to track which day it was update.


thank you very much. MODIFY_mDATE is used for optimistic locking,it stores in milliseconds,not for date, it prevent me updating.if i moved <Timestamp> tag,it can work well.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 11:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i have no idea what you just wrote ?

_________________
Max
Don't forget to rate


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