Example test:
Code:
public void testManySessions() throws Exception {
long t;
SessionFactory fac = HibernateProvider.getSessionFactory();
for (int i = 0; i < 10; i++) {
t = System.currentTimeMillis();
Session session = fac.openSession();
Kurz kurz = (Kurz) session.load(Kurz.class, new Long(1));
session.close();
log.debug("time: " + (System.currentTimeMillis() - t) + "ms");
}
}
Result:
Code:
16:22:23,687 DEBUG HibernateSimpleTest:134 - time: 2859ms
16:22:26,515 DEBUG HibernateSimpleTest:134 - time: 2828ms
16:22:29,421 DEBUG HibernateSimpleTest:134 - time: 2906ms
16:22:32,234 DEBUG HibernateSimpleTest:134 - time: 2813ms
16:22:35,093 DEBUG HibernateSimpleTest:134 - time: 2859ms
16:22:37,906 DEBUG HibernateSimpleTest:134 - time: 2797ms
16:22:40,734 DEBUG HibernateSimpleTest:134 - time: 2828ms
16:22:41,921 WARN SessionImpl:3358 - unclosed connection
16:22:41,968 WARN SessionImpl:3358 - unclosed connection
16:22:43,843 DEBUG HibernateSimpleTest:134 - time: 3109ms
16:22:46,656 DEBUG HibernateSimpleTest:134 - time: 2813ms
16:22:49,421 DEBUG HibernateSimpleTest:134 - time: 2765ms
Is this normal behaviour ?