HHH-8558 - Bytecode enhancer: fix classloading issues on testsuite

This commit is contained in:
barreiro 2015-06-16 18:00:18 +01:00 committed by Steve Ebersole
parent d5ed3a87c4
commit 8053fa7698
3 changed files with 13 additions and 9 deletions

View File

@ -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" );
}

View File

@ -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() {

View File

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