Author: epbernard
Date: 2006-09-29 15:26:00 -0400 (Fri, 29 Sep 2006)
New Revision: 10538
Modified:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
Log:
EJB-231
Modified:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
---
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2006-09-29
19:18:26 UTC (rev 10537)
+++
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2006-09-29
19:26:00 UTC (rev 10538)
@@ -598,10 +598,16 @@
if ( e instanceof StaleStateException ) {
if ( e instanceof StaleObjectStateException ) {
StaleObjectStateException sose = (StaleObjectStateException) e;
- Object entity = getRawSession().load( sose.getEntityName(), sose.getIdentifier() );
- if ( entity instanceof Serializable ) {
- //avoid some user errors regarding boundary crossing
- throwPersistenceException( new OptimisticLockException( null, e, entity ) );
+ Serializable identifier = sose.getIdentifier();
+ if (identifier != null) {
+ Object entity = getRawSession().load( sose.getEntityName(), identifier );
+ if ( entity instanceof Serializable ) {
+ //avoid some user errors regarding boundary crossing
+ throwPersistenceException( new OptimisticLockException( null, e, entity ) );
+ }
+ else {
+ throwPersistenceException( new OptimisticLockException( e ) );
+ }
}
else {
throwPersistenceException( new OptimisticLockException( e ) );
Show replies by date