HHH-8558 - Bytecode enhancer: fix classloading issues on testsuite
This commit is contained in:
parent
d5ed3a87c4
commit
8053fa7698
|
@ -35,7 +35,7 @@ public class LazyAttributeLoader implements PersistentAttributeInterceptor {
|
|||
}
|
||||
|
||||
protected final Object intercept(Object target, String fieldName, Object value) {
|
||||
if ( lazyFields != null && lazyFields.contains( fieldName ) && initializedFields.contains( fieldName ) ) {
|
||||
if ( lazyFields != null && lazyFields.contains( fieldName ) && !initializedFields.contains( fieldName ) ) {
|
||||
if ( session == null ) {
|
||||
throw new LazyInitializationException( "entity with lazy properties is not associated with a session" );
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
package org.hibernate.test.bytecode.enhancement;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -21,18 +24,20 @@ public abstract class AbstractEnhancerTestTask implements EnhancerTestTask {
|
|||
private ServiceRegistry serviceRegistry;
|
||||
private SessionFactory factory;
|
||||
|
||||
public final void prepare(Configuration user) {
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.setProperties( user.getProperties() );
|
||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
public final void prepare(Configuration config) {
|
||||
config.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
|
||||
Class<?>[] resources = getAnnotatedClasses();
|
||||
for ( Class<?> resource : resources ) {
|
||||
cfg.addAnnotatedClass( resource );
|
||||
config.addAnnotatedClass( resource );
|
||||
}
|
||||
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||
factory = cfg.buildSessionFactory( serviceRegistry );
|
||||
StandardServiceRegistryBuilder serviceBuilder = new StandardServiceRegistryBuilder( );
|
||||
serviceBuilder.addService( ClassLoaderService.class, new ClassLoaderServiceImpl( Thread.currentThread().getContextClassLoader() ) );
|
||||
|
||||
serviceBuilder.applySettings( config.getProperties() );
|
||||
serviceRegistry = serviceBuilder.build();
|
||||
factory = config.buildSessionFactory( serviceRegistry );
|
||||
}
|
||||
|
||||
public final void complete() {
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.test.bytecode.enhancement.lazy;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
|
Loading…
Reference in New Issue