troubleshooting Question

getting staleStateException in Hibernate

Avatar of huzefaq
huzefaq asked on
JavaJava EE
6 Comments4 Solutions1901 ViewsLast Modified:
Hi guys

I  am getting the following error
----------
AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener performExecutions Could not synchronize database state with session
                                 org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
----------           when execute the following code


GeneralMaintenanceSequenceNumber sequence = new GeneralMaintenanceSequenceNumber(clientID, sequenceType);
Session hibernateSession = HibernateUtils.getSession();
hibernateSession.get(GeneralMaintenanceSequenceNumber.class, sequence);
int sequenceNumber = sequence.getSequenceNumber();

sequence.setSequenceNumber(sequenceNumber + 1);

hibernateSession.update(sequence);
hibernateSession.flush();
return sequenceNumber;

----------------
THE QUERIES WHICH RUN ARE AS FOLLOWS

SystemOut     O Hibernate: select generalmai0_.SNCID as SNCID3_0_, generalmai0_.SNTYPE as SNTYPE3_0_, generalmai0_.SNSNBR as SNSNBR3_0_ from OTSSNBR generalmai0_ where generalmai0_.SNCID=? and generalmai0_.SNTYPE=?

SystemOut     O Hibernate: update OTSSNBR set SNSNBR=? where SNCID=? and SNTYPE=?

---------

WOULD ANYONE KNOW ANYTHING ABOUT THIS ERROR
THANKS
ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 4 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros