// let all extensions add hibernate configuration, if needed
ExtManager extm = null;
try {
extm = ExtManager.getInstance();
} catch (Exception e) {
throw new OLATRuntimeException(this.getClass(), "Can not load extensions. Check xml files.", e);
}
Class extensionPoint = this.getClass();
int cnt = extm.getExtensionCnt();
for (int i = 0; i < cnt; i++) {
Extension anExt = extm.getExtension(i);
HibernateConfigurator hibconfigure = (HibernateConfigurator) anExt.getExtensionFor(extensionPoint.getName());
if (hibconfigure != null) {
hibconfigure.extend(cfg);
extm.inform(extensionPoint, anExt, "added hibernate configuration");
}
}
// set audit interceptor that traces lastChanged
cfg.setInterceptor(new AuditInterceptor());
cfg.setProperties(getConnectionProperties());
sessionFactory = cfg.buildSessionFactory();
registerStatisticsServiceAsMBean(sessionFactory);
try {
String lev = "n/a";
session = sessionFactory.openSession();
int iso = session.connection().getTransactionIsolation();
switch (iso) {
case Connection.TRANSACTION_READ_COMMITTED:
lev = "TRANSACTION_READ_COMMITTED";
break;
case Connection.TRANSACTION_READ_UNCOMMITTED:
lev = "TRANSACTION_READ_UNCOMMITTED";
break;
case Connection.TRANSACTION_REPEATABLE_READ:
lev = "TRANSACTION_REPEATABLE_READ";
break;
case Connection.TRANSACTION_SERIALIZABLE:
lev = "TRANSACTION_SERIALIZABLE";
break;
}
session.close();
logInfo("Transaction Level::::" + lev, null);
} catch (SQLException e) {
throw new DBRuntimeException("could not get TransactionIsolationLevel from db", e);
}
}
}
initializeSession();
// else we have an DBSession in the current thread, but check if
// session was closed
} else if (!dbs.isOpen()) {
initializeSession();
}
setInitialized(true);
} catch (HibernateException he) {
throw new OLATRuntimeException(DBImpl.class, "current session could not be obtained", he);
} finally {
if (isLogDebugEnabled()) logDebug("createSession finally...", null);
}
if (isLogDebugEnabled()) logDebug("createSession end...", null);
}