Forums Register Login

How to knock out StaleStateException

+Pie Number of slices to send: Send
I am doing a small database application using j2se and hibernate. For the same, I have two databases - one primary and the other secondary. So I opened two sessions - each connecting to primary and secondary databases respectively.
Here is code:




When I run the code, I am getting exception as below:
SEVERE: Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:222)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2354)
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 com.databaseclient.core.ApplicationTrigger.main(ApplicationTrigger.java:202)
Feb 6, 2009 11:03:52 AM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session

What is the approach for using two sessions in hibernate?
Anticipating early replies

Thank You
+Pie Number of slices to send: Send
I'm not quite so sure it has to do with using two sessions. Are you using mapping files or annoations? What Java type are you using for your identifier? Are you using a primitive type? Are you setting the unsaved-value attribute?

Can you show us your domain object?
What a stench! Central nervous system shutting down. Save yourself tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1620 times.
Similar Threads
org.hibernate.StaleStateException:
Hibernate 3.0 : Where am I going wrong?
How to solve this exception? and what the mistake I have done in my code??
Exception while inserting a row using Hibernate
Problem with inserting new data into database using hibernate
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:45:09.