-->
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: How to suppress org.hibernate.StaleStateException?
PostPosted: Sat Nov 06, 2010 6:38 pm 
Newbie

Joined: Sat Nov 06, 2010 6:02 pm
Posts: 1
We have an application that reads messages using JMS and commits them Sybase database. One of the table in the database has a trigger associated with it. The Trigger basically checks for some value based on a condition in inserted table and does something. below is the basic working of the trigger.

if (select count(*) from inserted where condition = condition1)>0
begin
do something
end

Now, when we are inserting/updating on this underlying table where the "condition1" happens to be something else that what the trigger is checking the returned rowcount is 0. While the hibernate that is inserting/updating into the database table is expecting rowcount to be 1 to complete its transaction. Hibernate encounters the following eror

"ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1"

and tries to rollback. but, the session doesn't have the transactional state to rollback. NOTE: the insert/update anyway happens.

When I try simulate this exception by processing the message from a file WITHOUT connecting to JMS, the exception doesn't seems to happen or at least I m seeing in the logs/console.

What I request to know from other experts are the following.

1. How to suppress the exception (as it anyway insert/updates the table)?
2. Is the JMS connection/session has something to do with hibernate session that I believe is hijacked by the trigger which causes the exception?

Disabling the trigger is not an option but, I m considering a different way to check within the trigger which would always return the number of record(s) inserted/updated would possible help this situation. I haven't yet tried out that but, I wanted to know some details on the above questions.

Any suggestions or pointer are welcome.

Rgds.


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.