-->
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: Could not synchronize database state with session
PostPosted: Tue Sep 18, 2007 11:09 am 
Newbie

Joined: Tue Sep 18, 2007 10:31 am
Posts: 1
During my attempt to migrate from Hibernate 2.x to Hibernate 3 I've run up against a problem. I'm having an issue when trying to update a persistent object within a transaction. I'm able to retrieve the object but any attempt to update a value in the object causes an exception to be thrown. The example below involves just updating a single value in the object. I would appreciate any incite anyone might have or ideas to try or if I need to provide further information.

Paul

Hibernate version: 3.2.4.sp1
Spring version: 1.2.6
Oracle 10.2.0.2.0
JBoss 4.2.1



<class
name="com.sitestuff.contract.domain.rfp.RFPProxy"
table="RFPS"
optimistic-lock="none"
>
<cache usage="read-write" />

<id
name="id"
column="RFP_ID"
type="int"
>
<generator class="sequence">
<param name="sequence">RFP_SEQ</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-RFPProxy.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>



Code:
    public void saveRFPTemplateId(int rfpId, int rfpTemplateId) {
        getRFPDataMapper().saveRFPTemplateId(rfpId, rfpTemplateId);
    }


    public void saveRFPTemplateId(final int rfpId, final int rfpTemplateId) {
        getHibernateTemplate().execute(new HibernateCallback() {
            public Object doInHibernate(Session session)
                    throws HibernateException {
                RFP rfp = (RFP) session.load(RFP.class, new Integer(rfpId));

                if (rfp != null) {
                    if (rfpTemplateId == CommonCodes.NULL_INTEGER) {
                        rfp.setTemplateId(null);
                    } else {
                        rfp.setTemplateId(new Integer(rfpTemplateId));
                    }

                    session.saveOrUpdate(rfp);
                }

                return rfp;
            }
        });
    }




2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@1462704]

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.springframework.jdbc.datasource.ConnectionHolder@1526c5f] for key [org.apache.commons.dbcp.BasicDataSource@2afee5] to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Initializing transaction synchronization

2007-09-18 09:19:18,824 DEBUG [org.springframework.aop.support.JdkRegexpMethodPointcut] Candidate is [com.sitestuff.contract.service.rfp.mapper.RFPDataMapper.saveRFPTemplateId]; pattern is [com\.sitestuff\.contract\.service\.rfp\.mapper\..*load.*]; matched=false

2007-09-18 09:19:18,824 DEBUG [org.springframework.aop.support.JdkRegexpMethodPointcut] Candidate is [com.sitestuff.contract.service.rfp.mapper.RFPDataMapper.saveRFPTemplateId]; pattern is [com\.sitestuff\.contract\.service\.rfp\.mapper\..*save.*]; matched=true

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Found thread-bound Session [org.hibernate.impl.SessionImpl@1228521] for Hibernate transaction

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1526c5f] for key [org.apache.commons.dbcp.BasicDataSource@2afee5] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@1b43ff9]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Participating in existing transaction

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Invoking commit for transaction on com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Found thread-bound Session [org.hibernate.impl.SessionImpl@1228521] for Hibernate transaction

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1526c5f] for key [org.apache.commons.dbcp.BasicDataSource@2afee5] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@d409d2]

2007-09-18 09:19:18,824 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Participating in existing transaction

2007-09-18 09:19:18,824 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Invoking commit for transaction on com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,840 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,840 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,840 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Found thread-bound Session for HibernateTemplate

2007-09-18 09:19:18,840 DEBUG [org.hibernate.impl.SessionImpl] initializing proxy: [com.sitestuff.contract.domain.rfp.RFP#34688]

2007-09-18 09:19:18,840 DEBUG [org.hibernate.cache.EhCache] key: com.sitestuff.contract.domain.rfp.RFP#34688

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Not closing pre-bound Hibernate Session after HibernateTemplate

2007-09-18 09:19:18,855 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,855 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@490a12] for key [org.hibernate.impl.SessionFactoryImpl@7014a] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Found thread-bound Session [org.hibernate.impl.SessionImpl@1228521] for Hibernate transaction

2007-09-18 09:19:18,855 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1526c5f] for key [org.apache.commons.dbcp.BasicDataSource@2afee5] bound to thread [http-127.0.0.1-8080-1]

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@1d04ef]

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Participating in existing transaction

2007-09-18 09:19:18,855 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Invoking commit for transaction on com.sitestuff.contract.framework.security.AuthorizationManager.authorize

2007-09-18 09:19:18,855 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Invoking commit for transaction on com.sitestuff.contract.service.rfp.RFPService.saveRFPTemplateId

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Triggering beforeCommit synchronization

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Triggering beforeCompletion synchronization

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Initiating transaction commit

2007-09-18 09:19:18,855 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1228521]

2007-09-18 09:19:18,855 DEBUG [org.hibernate.transaction.JDBCTransaction] commit

2007-09-18 09:19:18,855 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades

2007-09-18 09:19:18,855 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.RFPAttachments#34688], was: [com.sitestuff.contract.domain.rfp.RFP.RFPAttachments#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.addenda#34688], was: [com.sitestuff.contract.domain.rfp.RFP.addenda#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.properties#34688], was: [com.sitestuff.contract.domain.rfp.RFP.properties#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.questions#34688], was: [com.sitestuff.contract.domain.rfp.RFP.questions#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.specifications#34688], was: [com.sitestuff.contract.domain.rfp.RFP.specifications#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.engine.Collections] Collection found: [com.sitestuff.contract.domain.rfp.RFP.recipients#34688], was: [com.sitestuff.contract.domain.rfp.RFP.recipients#34688] (uninitialized)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects

2007-09-18 09:19:18,855 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 6 collections

2007-09-18 09:19:18,855 DEBUG [org.hibernate.pretty.Printer] listing entities:

2007-09-18 09:19:18,855 DEBUG [org.hibernate.pretty.Printer] com.sitestuff.contract.domain.rfp.RFP{createdDate=2007-09-17 15:20:43, deleteDate=null, currentAnnualServiceCost=50000, attachmentCompleteIndicator=false, awardDate=null, title=Test Hibernate 9/17a, address=com.sitestuff.contract.domain.common.Address#173846, notifiedOfDelayedAward=false, stepNumber=2, groupBid=false, properties=<uninitialized>, id=34688, currentServiceProviderCompanyName=none, notifyDate=null, questions=<uninitialized>, recipients=<uninitialized>, addenda=<uninitialized>, specifications=<uninitialized>, lateBidCloseDate=null, previousRFPId=null, summary=null, RFPAttachments=<uninitialized>, prebidMtgDate=null, updatedDate=2007-09-18 09:19:05, propertyManagerUserId=21261, sentDate=null, status=I, templateId=1768, numberOfBuildings=1, accountId=45223, squareFootage=600000, ccEmail=null, originalRFPId=34688, clientId=0, categoryId=115, duration=2, versionNumber=0, closeDate=2007-10-17 17:00:00}

2007-09-18 09:19:18,855 DEBUG [org.hibernate.cache.EhCache] key: com.sitestuff.contract.domain.rfp.RFP#34688

2007-09-18 09:19:18,855 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)

2007-09-18 09:19:18,855 DEBUG [org.hibernate.SQL]
update
RFPS
set
UPDATED_DATE=?,
NOTIFY_DATE=?,
CC_EMAIL=?,
DURATION=?,
LATE_BID_CLOSE_DATE=?,
GLOBAL_ADDRESS_ID=?,
CURRENT_MONTHLY_SERVICE_COST=?,
CURRENT_SP_COMPANY_NAME=?,
NUMBER_OF_BUILDINGS=?,
IS_GROUP_BID=?,
SQUARE_FOOTAGE=?,
NOTIFIED_DELAYED_AWARD=?,
RFP_TEMPLATE_ID=?,
PREBID_MEETING_DATE=?,
CLOSE_DATE=?,
CATEGORY_ID=?,
RFP_STATUS=?,
RFP_TITLE=?,
SUMMARY=?,
ORIGINAL_RFPID=?,
VERSION_NUM=?,
PREVIOUS_VERSION=?,
STEP_NUM=?,
AWARD_DATE=?,
SENT_DATE=?,
DELETE_DATE=?,
ATTACHMENT_COMPLETE_IND=?
where
RFP_ID=?
and UPDATED_DATE=?

2007-09-18 09:19:18,855 INFO [STDOUT] Hibernate:
update
RFPS
set
UPDATED_DATE=?,
NOTIFY_DATE=?,
CC_EMAIL=?,
DURATION=?,
LATE_BID_CLOSE_DATE=?,
GLOBAL_ADDRESS_ID=?,
CURRENT_MONTHLY_SERVICE_COST=?,
CURRENT_SP_COMPANY_NAME=?,
NUMBER_OF_BUILDINGS=?,
IS_GROUP_BID=?,
SQUARE_FOOTAGE=?,
NOTIFIED_DELAYED_AWARD=?,
RFP_TEMPLATE_ID=?,
PREBID_MEETING_DATE=?,
CLOSE_DATE=?,
CATEGORY_ID=?,
RFP_STATUS=?,
RFP_TITLE=?,
SUMMARY=?,
ORIGINAL_RFPID=?,
VERSION_NUM=?,
PREVIOUS_VERSION=?,
STEP_NUM=?,
AWARD_DATE=?,
SENT_DATE=?,
DELETE_DATE=?,
ATTACHMENT_COMPLETE_IND=?
where
RFP_ID=?
and UPDATED_DATE=?

2007-09-18 09:19:18,855 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)

2007-09-18 09:19:18,855 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): [com.sitestuff.contract.domain.rfp.RFP#34688]

at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)

at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)

at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)

at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)

at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)

at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:586)

at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:564)

at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:537)

at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:267)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:169)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:169)

at $Proxy61.saveRFPTemplateId(Unknown Source)

at com.sitestuff.contract.web.rfp.SelectTemplateAction.save(SelectTemplateAction.java:127)


Again, any help or ideas would be appreciated. Thanks.


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.