I have a table with 8 columns C1,C2,C3,C4,C5,C6,C7,C8, where combination of {C1,C2,C3} is a composite key.
I want to update only C2's data, but when I try to update that it's showing an exception:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
Is it possible to update this in Hibernate?
I am using code --
public static synchronized Session getSession() {
Session mysession = (Session) DAO.session.get();
if (mysession == null||!mysession.isOpen()) {
mysession = sessionFactory.openSession();
DAO.session.set(mysession);
}
return mysession;
}
protected void begin() {
try{
getSession().beginTransaction();
}catch(Exception ex)
{
LOGGER.error(ex);
}
} public void update(Facebook facebookdata){ begin();
getSession().update(facebookdata);
commit();
}