mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
Adding 'serviceRegistryHolder' instance variable due to changes commited on master for Configuration class
This commit is contained in:
parent
83b1f22ea9
commit
0541cbf966
@ -8,8 +8,10 @@
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.AuditReaderFactory;
|
||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -27,6 +29,7 @@ public abstract class AbstractOneSessionTest {
|
||||
|
||||
|
||||
protected Configuration config;
|
||||
private ServiceRegistryHolder serviceRegistryHolder;
|
||||
private SessionFactory sessionFactory;
|
||||
private Session session ;
|
||||
private AuditReader auditReader;
|
||||
@ -45,7 +48,8 @@ public void init(@Optional String auditStrategy) throws URISyntaxException {
|
||||
|
||||
this.initMappings();
|
||||
|
||||
sessionFactory = config.buildSessionFactory();
|
||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
||||
sessionFactory = config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
||||
}
|
||||
|
||||
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
||||
@ -61,7 +65,15 @@ private SessionFactory getSessionFactory(){
|
||||
|
||||
@AfterClass
|
||||
public void closeSessionFactory() {
|
||||
sessionFactory.close();
|
||||
try {
|
||||
sessionFactory.close();
|
||||
}
|
||||
finally {
|
||||
if ( serviceRegistryHolder != null ) {
|
||||
serviceRegistryHolder.destroy();
|
||||
serviceRegistryHolder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user