public boolean isAutoCloseSessionEnabled() { return factory.getSettings().isAutoCloseSessionEnabled(); }
public ConnectionReleaseMode getConnectionReleaseMode() { return factory.getSettings().getConnectionReleaseMode(); }
private SessionFactory injectInSessionFactory(Configuration config) throws XWikiException { SessionFactoryImpl sfactory = (SessionFactoryImpl) config.buildSessionFactory(); Settings settings = sfactory.getSettings(); ConnectionProvider provider = ((SessionFactoryImpl) getSessionFactory()).getSettings().getConnectionProvider(); Field field = null; try { field = settings.getClass().getDeclaredField("connectionProvider"); field.setAccessible(true); field.set(settings, provider); } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_MAPPING_INJECTION_FAILED, "Mapping injection failed", e); } return sfactory; }
private SessionFactory injectCustomMappingsInSessionFactory(XWikiDocument doc, XWikiContext context) throws XWikiException { // If we haven't turned of dynamic custom mappings we should not inject them if (context.getWiki().hasDynamicCustomMappings() == false) { return getSessionFactory(); } boolean result = injectCustomMappings(doc, context); if (result == false) { return getSessionFactory(); } Configuration config = getConfiguration(); SessionFactoryImpl sfactory = (SessionFactoryImpl) config.buildSessionFactory(); Settings settings = sfactory.getSettings(); ConnectionProvider provider = ((SessionFactoryImpl) getSessionFactory()).getSettings().getConnectionProvider(); Field field = null; try { field = settings.getClass().getDeclaredField("connectionProvider"); field.setAccessible(true); field.set(settings, provider); } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_MAPPING_INJECTION_FAILED, "Mapping injection failed", e); } return sfactory; }