-->
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: org.hibernate.StaleObjectStateException
PostPosted: Thu Jul 20, 2006 11:38 pm 
Newbie

Joined: Thu Jul 20, 2006 11:26 pm
Posts: 2
Hibernate version 3.0

Mapping document:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false">
<class name="com.integrosys.etreasury.app.alert.OBAlert" table="ET_ALERT"
dynamic-update="false"
dynamic-insert="false"
lazy="false"
>
<id name="alertID" column="ALERT_ID" type="long">
<generator class="assigned"/>
</id>
<version name="versionTime" column="VERSION_TIME" type="long"/>
<property name="alertRate" column="ALERT_RATE" type="java.math.BigDecimal"/>
<property name="valueDate" column="VALUE_DATE" />
<property name="alertRefCode" column="ALERT_REF_CODE"/>
<property name="alertStatus" column="ALERT_STATUS"/>
<property name="lastUpdatedDateTime" column="LAST_UPDATED_DATE_TIME"/>
<property name="orderDate" column="ORDER_DATE"/>
<property name="customerID" column="CUSTOMER_ID"/>
<property name="buySellInd" column="BUY_SELL_IND"/>



when i am using this object, it gives org.hibernate.StaleObjectStateException

But i am catching this exception, and doing nothing, then also this exception message display in my console.


The message is:

ERROR - 21 Jul 2006 10:57:47,740: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.integrosys.etreasury.app.alert.OBAlert#2004071500000351]
at org.hibernate.persister.entity.BasicEntityPersister.check(BasicEntityPersister.java:1456)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1999)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1923)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2163)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:675)
at org.springframework.orm.hibernate3.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:827)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:530)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:390)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:256)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy11.updateAlert(Unknown Source)




But in the console, i don't want to display this message, How i will do that?


give reply

thanks
chidam


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 12:21 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You're not catching that exception. If you were, it wouldn't be appearing on the console.

You don't want to just catch the exception and throw it away. At the very least, you have to clean your hibernate session.

According to the trace, none of your code is in a position to catch that exception. So you're going to have to do something else to prevent this. You could declare all your classes (or at least this one) to be select-before-update, though that would slow the app down a bit. Alternatively, you could refresh the object just before saving it. Or you could evict the object, then use session.merge() to save it.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 12:06 am 
Newbie

Joined: Thu Jul 20, 2006 11:26 pm
Posts: 2
No, I am catching that exception,

I am getting the object using the primary key, Setting object some value, and updating.

One more issue, when i am setting

<prop key="hibernate.show_sql">false</prop>, in the console it is printing the sql query


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 12:54 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If you are catching that exception, where is your method in the call stack?
Code:
ERROR - 21 Jul 2006 10:57:47,740: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.integrosys.etreasury.app.alert.OBAlert#2004071500000351]
at org.hibernate.persister.entity.BasicEntityPersister.check(BasicEntityPersister.java:1456)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1999)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1923)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2163)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:675)
at org.springframework.orm.hibernate3.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:827)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:530)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:390)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:256)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy11.updateAlert(Unknown Source)
Which line is yours? If it's not there, then you are not catching that particular exception. This particular exception is being thrown from somewhere that you're not catching. Possibly there's a caused-by part of the exception that you've deleted? Or a few lines that you've removed?

About the show_sql thing: check your .cfg.xml files and configuration source code for places where you're setting hibernate.show_sql to true. You don't need to set it to false, that's the default. If you set it to false then later set it to true, the true value is used.

Also, if you do set it to false, you could try the correct syntax:
Code:
<property name="hibernate.show_sql">false</property>

_________________
Code tags are your friend. Know them and use them.


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.