Hi,
Since upgrading from Hibernate 3.1.3 to 3.2.5, I'm receiving exceptions in persistence of fields that map to identity columns:
... snip ...
Code:
Caused by: org.springframework.orm.hibernate3.HibernateSystemException: Provided id of the wrong type. Expected: class java.lang.Integer, got class org.hibernate.action.DelayedPostInsertIdentifier; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class org.hibernate.action.DelayedPostInsertIdentifier
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:668)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:408)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
at org.springframework.orm.hibernate3.HibernateTemplate.merge(HibernateTemplate.java:752)
This exception only occurs in the following situation:
1. Transaction opened
2. Class is opened via Hibernate:
Code:
getHibernateTemplate().load(entityClass, oid);
3. Entry is added to a mapped list in the class
4. Class is saved via Hibernate:
Code:
getHibernateTemplate().merge(entity);
5. Exception occurs in persistence of entry added in step 3.
Note that this exception doesn't occur when the class is saved as part of a separate transaction from opening.
Looking at the Javadocs for DelayedPostInsertIdentifier, it appears that this should only be present when classes are being persisted outside of a transaction so am unsure why this is happening in this - and only this - situation.
Transaction management in the application is being handled by Spring's TransactionProxyFactoryBean and all methods are set to PROPAGATION_REQUIRED.
We're using JBoss's JTA transaction manager but we are only using JBoss 4.0.1 - is this still supported by Hibernate 3.2?