Hi everyone.
I'm having trouble upgrading my jdbc driver with Hibernate.
When I'm updating a column with is NOT the <version .. /> column, I get a StaleObjectStateException, using JDBC driver 9.2.0.5.0 (Oracle Thin Driver ojdbc14-9.2.0.5.jar).
When I'm using a previous driver (Oracle Jdbc Driver 8.1.7.1.0 ; classes12.jar) I dot not have this exception.
Can someone help me ?
Is this a JDBC Driver bug ?
An Hibernate bug ?
An uncorrect coding bug ?
Thanks for any help.
Hibernate version: 2.1.3
Mapping documents: <class name="com.etc.Incident" table="INCIDENT"> <id column="PK_INCIDENT" name="id" type="java.lang.Long"> <generator class="sequence"> <param name="sequence">S_INCIDENT</param> </generator> </id> <version column="DATE_MODIFIED" name="dateModified" type="timestamp" /> <property column="FK_CURRENT_DOCUMENT" length="3" name="fkCurrentVersionDocument" type="java.lang.Long"/> ... </class>
Code between sessionFactory.openSession() and session.close(): tx = session.beginTransaction(); IncidentDAO dao = factory.getIncidentDAO(session); Incident incident = new Incident(); incident.fillNewIncidentInfo(); dao.save(incident);
Document doc = incident.getCurrentDocument(); doc.filNewDocInfo(); dao.save(doc);
// For test purpose try { session.commit(tx); } catch (Exception e) { e.printStackTrace(); }
session.evict(incident);
tx = session.beginTransaction();
// End of test
incident.setFkCurrentVersionDocument(doc.getId());
// incident.dateModified is the same in database and in object (debug test)
dao.update(incident);
try { session.commit(tx); } catch (Exception e) { e.printStackTrace(); }
Full stack trace of any exception that occurs: net.sf.hibernate.StaleObjectStateException TRAS0014I: The following exception was logged net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for com.valeo.srm.ims.bo.IncidentHeader instance with identifier: 1496 at net.sf.hibernate.persister.AbstractEntityPersister.check(AbstractEntityPersister.java:513) at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:664) at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:621) at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2393) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261) at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61) at com.valeo.srm.dao.DAOHibernateSession.commit(DAOHibernateSession.java:41) at com.valeo.srm.ims.service.IncidentManager.save(IncidentManager.java:2346)
Name and version of the database you are using: Oracle 9.2.0.1.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: Fatal
|