7
7
package org .hibernate .test .bytecode .enhancement ;
8
8
9
9
import org .hibernate .SessionFactory ;
10
+ import org .hibernate .boot .registry .StandardServiceRegistryBuilder ;
11
+ import org .hibernate .boot .registry .classloading .internal .ClassLoaderServiceImpl ;
12
+ import org .hibernate .boot .registry .classloading .spi .ClassLoaderService ;
10
13
import org .hibernate .cfg .Configuration ;
11
14
import org .hibernate .cfg .Environment ;
12
15
import org .hibernate .service .ServiceRegistry ;
@@ -21,18 +24,20 @@ public abstract class AbstractEnhancerTestTask implements EnhancerTestTask {
21
24
private ServiceRegistry serviceRegistry ;
22
25
private SessionFactory factory ;
23
26
24
- public final void prepare (Configuration user ) {
25
- Configuration cfg = new Configuration ();
26
- cfg .setProperties ( user .getProperties () );
27
- cfg .setProperty ( Environment .HBM2DDL_AUTO , "create-drop" );
27
+ public final void prepare (Configuration config ) {
28
+ config .setProperty ( Environment .HBM2DDL_AUTO , "create-drop" );
28
29
29
30
Class <?>[] resources = getAnnotatedClasses ();
30
31
for ( Class <?> resource : resources ) {
31
- cfg .addAnnotatedClass ( resource );
32
+ config .addAnnotatedClass ( resource );
32
33
}
33
34
34
- serviceRegistry = ServiceRegistryBuilder .buildServiceRegistry ( cfg .getProperties () );
35
- factory = cfg .buildSessionFactory ( serviceRegistry );
35
+ StandardServiceRegistryBuilder serviceBuilder = new StandardServiceRegistryBuilder ( );
36
+ serviceBuilder .addService ( ClassLoaderService .class , new ClassLoaderServiceImpl ( Thread .currentThread ().getContextClassLoader () ) );
37
+
38
+ serviceBuilder .applySettings ( config .getProperties () );
39
+ serviceRegistry = serviceBuilder .build ();
40
+ factory = config .buildSessionFactory ( serviceRegistry );
36
41
}
37
42
38
43
public final void complete () {
0 commit comments