Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Hibernate database Session with flush() ?

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am facing problem while calling method

1) DB.flush();

2) public static void flush() {
LOG.debug(".... Flush ....");
HibernateUtil.getSession().flush();
}

3)

public static Session getSession()
throws InfrastructureException {
Session s = threadSession.get();
try {
if (s == null) {
LOG.debug("Opening new Session for this thread.");
if (getInterceptor() != null) {
LOG.info("Using interceptor: " + getInterceptor().getClass());
s = getSessionFactory().openSession(getInterceptor());
} else {
LOG.debug("No intereptor");
s = getSessionFactory().openSession();
LOG.debug("Got session");
}
threadSession.set(s);
LOG.debug("Put session in threadsession");
}
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}

// never auto flush
s.setFlushMode(FlushMode.MANUAL);

return s;
}

After wards i am getting error like :

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
and

2009-08-07 10:58:19,005 ERROR http-8084-Processor25 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

could you have any clue to resolve this issue.

Regards,
xyz
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting the exception in all three cases or .. ?

And I don't understand the below code ?


And please use code tags when posting code.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i am getting 1 exception , when the Db.flush() method finishes the call...and i have shown the three methods which using in call...

and theradSession is : instance of ThreadLocal..

private static final ThreadLocal<Session> threadSession = new ThreadLocal<Session>();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic