HHH-13020 - When proxying an entity having a private default constructor, the log message is not very clear about the problem

Fix test failing with Javassist
This commit is contained in:
Vlad Mihalcea 2018-10-10 20:41:26 +03:00
parent ceb83264fc
commit b6b9468fd0
1 changed files with 24 additions and 4 deletions

View File

@ -17,10 +17,13 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.SessionImpl;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.proxy.ProxyFactory;
import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyFactory;
import org.hibernate.proxy.pojo.javassist.JavassistProxyFactory;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule;
@ -38,7 +41,11 @@ import static org.junit.Assert.assertTrue;
public class PrivateConstructorTest extends BaseEntityManagerFunctionalTestCase {
@Rule
public LoggerInspectionRule logInspection = new LoggerInspectionRule( Logger.getMessageLogger( CoreMessageLogger.class, ByteBuddyProxyFactory.class.getName() ) );
public LoggerInspectionRule logInspection = new LoggerInspectionRule( Logger.getMessageLogger(
CoreMessageLogger.class,
proxyFactoryClass()
.getName()
) );
@Override
protected Class<?>[] getAnnotatedClasses() {
@ -92,6 +99,19 @@ public class PrivateConstructorTest extends BaseEntityManagerFunctionalTestCase
}
}
private static Class<? extends ProxyFactory> proxyFactoryClass() {
String byteCodeProvider = Environment.getProperties().getProperty( AvailableSettings.BYTECODE_PROVIDER );
if ( byteCodeProvider == null || Environment.BYTECODE_PROVIDER_NAME_BYTEBUDDY.equals( byteCodeProvider ) ) {
return ByteBuddyProxyFactory.class;
}
else if ( Environment.BYTECODE_PROVIDER_NAME_JAVASSIST.equals( byteCodeProvider ) ) {
return JavassistProxyFactory.class;
}
else {
throw new UnsupportedOperationException( "Unknown bytecode provider:" + byteCodeProvider );
}
}
@Entity(name = "Parent")
public static class Parent {