HHH-4822 Added handling of sessions == null in case openSession is called
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18604 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
9bb0da4e69
commit
70ddcd81f2
|
@ -53,15 +53,28 @@ public abstract class TestCase extends HibernateTestCase {
|
|||
}
|
||||
|
||||
public Session openSession() throws HibernateException {
|
||||
rebuildSessionFactory();
|
||||
session = getSessions().openSession();
|
||||
return session;
|
||||
}
|
||||
|
||||
public Session openSession(Interceptor interceptor) throws HibernateException {
|
||||
rebuildSessionFactory();
|
||||
session = getSessions().openSession( interceptor );
|
||||
return session;
|
||||
}
|
||||
|
||||
private void rebuildSessionFactory() {
|
||||
if ( sessions == null ) {
|
||||
try {
|
||||
buildConfiguration();
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new HibernateException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSessions(SessionFactory sessions) {
|
||||
TestCase.sessions = sessions;
|
||||
}
|
||||
|
@ -72,7 +85,6 @@ public abstract class TestCase extends HibernateTestCase {
|
|||
|
||||
@Override
|
||||
protected void buildConfiguration() throws Exception {
|
||||
|
||||
if ( getSessions() != null ) {
|
||||
getSessions().close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue