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 11e96fa039
commit 3f0277a33d
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.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" );
}
}

View File

@ -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