/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be * using * @param classLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) { getProperties() .put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); getProperties().put(Environment.DATASOURCE, dataSource); getProperties().put("hibernate.classLoader.application", resourceLoader.getClassLoader()); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
/** * Create a new LocalSessionFactoryBuilder for the given DataSource. * * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be * using (may be {@code null}) * @param resourceLoader the ResourceLoader to load application classes from */ @SuppressWarnings("deprecation") // to be able to build against Hibernate 4.3 public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) { getProperties() .put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(Environment.DATASOURCE, dataSource); } // APP_CLASSLOADER is deprecated as of Hibernate 4.3 but we need to remain compatible with 4.0+ getProperties().put(AvailableSettings.APP_CLASSLOADER, resourceLoader.getClassLoader()); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
/** * Loads the repository interface contained in the given {@link RepositoryConfiguration} using the * given {@link ResourceLoader}. * * @param configuration must not be {@literal null}. * @param loader must not be {@literal null}. * @return the repository interface or {@literal null} if it can't be loaded. */ private Class<?> loadRepositoryInterface( RepositoryConfiguration<?> configuration, ResourceLoader loader) { String repositoryInterface = configuration.getRepositoryInterface(); ClassLoader classLoader = loader.getClassLoader(); try { return org.springframework.util.ClassUtils.forName(repositoryInterface, classLoader); } catch (ClassNotFoundException e) { LOGGER.warn( String.format(CLASS_LOADING_ERROR, getModuleName(), repositoryInterface, classLoader), e); } catch (LinkageError e) { LOGGER.warn( String.format(CLASS_LOADING_ERROR, getModuleName(), repositoryInterface, classLoader), e); } return null; }
public ClassLoader getClassLoader() { return delegate.getClassLoader(); }