-->
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.  [ 1 post ] 
Author Message
 Post subject: StaleObjectStateException when save an object and update it
PostPosted: Tue Aug 29, 2006 5:18 am 
Newbie

Joined: Tue Aug 29, 2006 4:52 am
Posts: 1
I use tiemstamp to auto version. the map file for timestamp perperty like this: <timestamp name="updateTime" column="更新時刻"/>
The type in model object is java.util.Date, in DB is date.
When execute to transaction.commit() StaleObjectStateException thrown.
Code:
            beginTransaction();
            
            ConstructionOrder order = new ConstructionOrder();
            order.setServiceAreaCode("1");
            order.setServiceContractCode("2");
            order.setContractYear("2006");
            order.setCnsYmd(new Date(2006,10,1));
            order.setRecodeNo(new Integer(4));
            order.setOrderSourceCode("3");
            
            session.save(order);
            session.flush();
            Criteria criteria = session.createCriteria(ConstructionOrder.class);
            criteria.add(Restrictions.eq("serviceAreaCode", "1"));
            criteria.add(Restrictions.eq("serviceContractCode", "2"));
            criteria.add(Restrictions.eq("contractYear", "2006"));
            criteria.add(Restrictions.eq("orderSourceCode", "3"));
         
            
            List list = criteria.list();
            order = (ConstructionOrder) list.get(0);
            order.setAddress("sss");
            session.update(order);
         
            transaction.commit();


2006-08-29 18:04:31,125 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [jp.co.comsys.usss.domain.order.model.ConstructionOrder#jp.co.comsys.usss.domain.order.model.ConstructionOrder@8312fa51]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at jp.co.comsys.usss.persistence.hibernate.ConstructionDAO.testCRUD(ConstructionDAO.java:381)
at jp.co.comsys.usss.domain.construction.ConstructionLedger.main(ConstructionLedger.java:576)
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [jp.co.comsys.usss.domain.order.model.ConstructionOrder#jp.co.comsys.usss.domain.order.model.ConstructionOrder@8312fa51]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at jp.co.comsys.usss.persistence.hibernate.ConstructionDAO.testCRUD(ConstructionDAO.java:381)
at jp.co.comsys.usss.domain.construction.ConstructionLedger.main(ConstructionLedger.java:576)
org.hibernate.HibernateException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [jp.co.comsys.usss.domain.order.model.ConstructionOrder#jp.co.comsys.usss.domain.order.model.ConstructionOrder@8312fa51]
at jp.co.comsys.usss.persistence.hibernate.ConstructionDAO.testCRUD(ConstructionDAO.java:385)
at jp.co.comsys.usss.domain.construction.ConstructionLedger.main(ConstructionLedger.java:576)
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [jp.co.comsys.usss.domain.order.model.ConstructionOrder#jp.co.comsys.usss.domain.order.model.ConstructionOrder@8312fa51]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at jp.co.comsys.usss.persistence.hibernate.ConstructionDAO.testCRUD(ConstructionDAO.java:381)
... 1 more
Code:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.