Author: hardy.ferentschik
Date: 2010-01-21 21:16:10 -0500 (Thu, 21 Jan 2010)
New Revision: 18604
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/TestCase.java
Log:
HHH-4822 Added handling of sessions == null in case openSession is called
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/TestCase.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/TestCase.java 2010-01-22
01:55:20 UTC (rev 18603)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/TestCase.java 2010-01-22
02:16:10 UTC (rev 18604)
@@ -53,15 +53,28 @@
}
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 @@
@Override
protected void buildConfiguration() throws Exception {
-
if ( getSessions() != null ) {
getSessions().close();
}
Show replies by date