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.MappingException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.AuditReaderFactory;
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
|
import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -27,6 +29,7 @@ public abstract class AbstractOneSessionTest {
|
||||||
|
|
||||||
|
|
||||||
protected Configuration config;
|
protected Configuration config;
|
||||||
|
private ServiceRegistryHolder serviceRegistryHolder;
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
private Session session ;
|
private Session session ;
|
||||||
private AuditReader auditReader;
|
private AuditReader auditReader;
|
||||||
|
@ -45,7 +48,8 @@ public abstract class AbstractOneSessionTest {
|
||||||
|
|
||||||
this.initMappings();
|
this.initMappings();
|
||||||
|
|
||||||
sessionFactory = config.buildSessionFactory();
|
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
||||||
|
sessionFactory = config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
||||||
|
@ -61,8 +65,16 @@ public abstract class AbstractOneSessionTest {
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void closeSessionFactory() {
|
public void closeSessionFactory() {
|
||||||
|
try {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if ( serviceRegistryHolder != null ) {
|
||||||
|
serviceRegistryHolder.destroy();
|
||||||
|
serviceRegistryHolder = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new session and auditReader only if there is nothing created
|
* Creates a new session and auditReader only if there is nothing created
|
||||||
|
|
Loading…
Reference in New Issue