From: <hib...@li...> - 2006-05-28 15:28:14
|
Author: epbernard Date: 2006-05-28 11:28:12 -0400 (Sun, 28 May 2006) New Revision: 9952 Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java Log: EJB-98 em.remove() em.find() no longer fails EJB-185 align exceptions to glassfish EJB-186 change the default cache provider Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java =================================================================== --- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2006-05-28 15:20:06 UTC (rev 9951) +++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2006-05-28 15:28:12 UTC (rev 9952) @@ -154,6 +154,10 @@ try { return (A) getSession().get( entityClass, (Serializable) primaryKey ); } + catch (ObjectDeletedException e) { + //the spec is silent about people doing remove() find() on the same PC + return null; + } catch (ObjectNotFoundException e) { //should not happen on the entity itself with get throw new IllegalArgumentException( e.getMessage(), e ); @@ -555,13 +559,13 @@ throwPersistenceException( new EntityExistsException( e ) ); } else if ( e instanceof ObjectNotFoundException ) { - throwPersistenceException( new EntityNotFoundException( e ) ); + throwPersistenceException( new EntityNotFoundException( e.getMessage() ) ); } else if ( e instanceof org.hibernate.NonUniqueResultException ) { - throwPersistenceException( new NonUniqueResultException( e ) ); + throwPersistenceException( new NonUniqueResultException( e.getMessage() ) ); } else if ( e instanceof UnresolvableObjectException ) { - throwPersistenceException( new EntityNotFoundException( e ) ); + throwPersistenceException( new EntityNotFoundException( e.getMessage() ) ); } else { throwPersistenceException( new PersistenceException( e ) ); Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java =================================================================== --- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-05-28 15:20:06 UTC (rev 9951) +++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-05-28 15:28:12 UTC (rev 9952) @@ -39,9 +39,7 @@ import org.hibernate.HibernateException; import org.hibernate.Interceptor; import org.hibernate.MappingException; -import org.hibernate.ObjectNotFoundException; import org.hibernate.SessionFactory; -import org.hibernate.reflection.java.xml.XMLContext; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; @@ -61,6 +59,7 @@ import org.hibernate.mapping.AuxiliaryDatabaseObject; import org.hibernate.mapping.PersistentClass; import org.hibernate.proxy.EntityNotFoundDelegate; +import org.hibernate.reflection.java.xml.XMLContext; import org.hibernate.secure.JACCConfiguration; import org.hibernate.transaction.JDBCTransactionFactory; import org.hibernate.util.CollectionHelper; @@ -94,9 +93,7 @@ cfg.setEntityNotFoundDelegate( new EntityNotFoundDelegate() { public void handleEntityNotFound(String entityName, Serializable id) { - //keep the original ONFE for the sake of consistency in the way we handle Hibernate exceptions - Exception e = new ObjectNotFoundException( id, entityName ); - throw new EntityNotFoundException("Unable to find " + entityName + " with id " + id, e); + throw new EntityNotFoundException("Unable to find " + entityName + " with id " + id); } } ); listenerConfigurator = new EventListenerConfigurator( this ); @@ -836,6 +833,7 @@ //defaults different to Hibernate preparedProperties.setProperty( Environment.RELEASE_CONNECTIONS, "auto" ); + preparedProperties.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.NoCacheProvider" ); //use a string to avoid class loading //settings that always apply to a compliant EJB3 preparedProperties.setProperty( Environment.AUTOCOMMIT, "true" ); preparedProperties.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "false" ); |