diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/ToOneIdMapper.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/ToOneIdMapper.java index 91728d6d25..2d00782735 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/ToOneIdMapper.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/ToOneIdMapper.java @@ -20,6 +20,7 @@ import org.hibernate.envers.internal.tools.EntityTools; import org.hibernate.envers.internal.tools.query.Parameters; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.proxy.HibernateProxy; +import org.jboss.logging.Logger; import javax.persistence.PersistenceException; @@ -28,8 +29,10 @@ import javax.persistence.PersistenceException; * @author HernпїЅn Chanfreau * @author Michal Skowronek (mskowr at o2 dot pl) * @author Chris Cranford + * @author Luke Chen */ public class ToOneIdMapper extends AbstractToOneMapper { + private static final Logger log = Logger.getLogger( ToOneIdMapper.class ); private final IdMapper delegate; private final String referencedEntityName; private final boolean nonInsertableFake; @@ -67,8 +70,10 @@ public class ToOneIdMapper extends AbstractToOneMapper { if ( lazyMapping && entity instanceof HibernateProxy ) { try { entity = ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation(); - } catch ( PersistenceException e ) { - // Ignore the exception and fallback to call mapToMapFromEntity directly + } + catch ( PersistenceException e ) { + log.debug( "Ignore PersistenceException while initializing the entity, " + + "and fallback to call mapToMapFromEntity directly" ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyFetchTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyFetchTest.java index 5191cc1803..f7cea06d76 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyFetchTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyFetchTest.java @@ -32,7 +32,7 @@ public class ManyToOneLazyFetchTest extends BaseEnversFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { - return new Class[] { Shipment.class, Address.class, AddressVersion.class }; + return new Class[] { Shipment.class, Address.class, AddressVersion.class, User.class, ChildUser.class }; } @Test