HHH-13945: add debug log during exception thrown

This commit is contained in:
Luke Chen 2020-11-19 18:00:40 +08:00 committed by Christian Beikov
parent 2404ff56ab
commit e3a9ee61f2
2 changed files with 8 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import org.hibernate.envers.internal.tools.EntityTools;
import org.hibernate.envers.internal.tools.query.Parameters; import org.hibernate.envers.internal.tools.query.Parameters;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.jboss.logging.Logger;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
@ -28,8 +29,10 @@ import javax.persistence.PersistenceException;
* @author HernпїЅn Chanfreau * @author HernпїЅn Chanfreau
* @author Michal Skowronek (mskowr at o2 dot pl) * @author Michal Skowronek (mskowr at o2 dot pl)
* @author Chris Cranford * @author Chris Cranford
* @author Luke Chen
*/ */
public class ToOneIdMapper extends AbstractToOneMapper { public class ToOneIdMapper extends AbstractToOneMapper {
private static final Logger log = Logger.getLogger( ToOneIdMapper.class );
private final IdMapper delegate; private final IdMapper delegate;
private final String referencedEntityName; private final String referencedEntityName;
private final boolean nonInsertableFake; private final boolean nonInsertableFake;
@ -67,8 +70,10 @@ public class ToOneIdMapper extends AbstractToOneMapper {
if ( lazyMapping && entity instanceof HibernateProxy ) { if ( lazyMapping && entity instanceof HibernateProxy ) {
try { try {
entity = ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation(); 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" );
} }
} }

View File

@ -32,7 +32,7 @@ public class ManyToOneLazyFetchTest extends BaseEnversFunctionalTestCase {
@Override @Override
protected Class<?>[] getAnnotatedClasses() { 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 @Test