List of usage examples for org.hibernate.cfg AvailableSettings CLASSLOADERS
String CLASSLOADERS
To view the source code for org.hibernate.cfg AvailableSettings CLASSLOADERS.
Click Source Link
From source file:act.db.hibernate.HibernateBootstrap.java
License:Apache License
private Map integration() { List<?> classLoaders = C.list(Act.app().classLoader()); return C.Map(AvailableSettings.CLASSLOADERS, classLoaders); }
From source file:com.baomidou.hibernateplus.HibernateSpringSessionFactoryBuilder.java
License:Apache License
/** * 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 * @param metadataSources the Hibernate MetadataSources service to use (e.g. reusing an existing one) * @since 4.3/*from w w w . j a v a 2 s . com*/ */ public HibernateSpringSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) { super(metadataSources); getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(AvailableSettings.DATASOURCE, dataSource); } // Hibernate 5.1/5.2: manually enforce connection release mode ON_CLOSE (the former default) try { // Try Hibernate 5.2 AvailableSettings.class.getField("CONNECTION_HANDLING"); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD"); } catch (NoSuchFieldException ex) { // Try Hibernate 5.1 try { AvailableSettings.class.getField("ACQUIRE_CONNECTIONS"); getProperties().put("hibernate.connection.release_mode", "ON_CLOSE"); } catch (NoSuchFieldException ex2) { // on Hibernate 5.0.x or lower - no need to change the default there } } getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader())); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
From source file:org.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.java
License:Apache License
public void afterPropertiesSet() throws Exception { if (grailsApplication == null) { return;/* w w w .j av a2s. c om*/ } String dsName = Mapping.DEFAULT_DATA_SOURCE.equals(dataSourceName) ? "dataSource" : "dataSource_" + dataSourceName; getProperties().put(Environment.DATASOURCE, applicationContext.getBean(dsName)); getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, GrailsSessionContext.class.getName()); getProperties().put(AvailableSettings.CLASSLOADERS, grailsApplication.getClassLoader()); resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(applicationContext); configureNamingStrategy(); GrailsClass[] existingDomainClasses = grailsApplication.getArtefacts(DomainClassArtefactHandler.TYPE); for (GrailsClass existingDomainClass : existingDomainClasses) { addDomainClass((GrailsDomainClass) existingDomainClass); } ArtefactHandler handler = grailsApplication.getArtefactHandler(DomainClassArtefactHandler.TYPE); if (!(handler instanceof AnnotationDomainClassArtefactHandler)) { return; } Set<String> jpaDomainNames = ((AnnotationDomainClassArtefactHandler) handler).getJpaClassNames(); if (jpaDomainNames == null) { return; } final ClassLoader loader = grailsApplication.getClassLoader(); for (String jpaDomainName : jpaDomainNames) { try { addAnnotatedClass(loader.loadClass(jpaDomainName)); } catch (ClassNotFoundException e) { // impossible condition } } }
From source file:org.lightmare.jpa.hibernate.boot.registry.classloading.internal.ClassLoaderServiceExt.java
License:Open Source License
/** * No longer used/supported!/* w ww . ja v a 2 s .co m*/ * * @param configValues * The config values * * @return The built service * * @deprecated No longer used/supported! */ @Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) public static ClassLoaderServiceExt fromConfigSettings(Map configValues) { final List<ClassLoader> providedClassLoaders = new ArrayList<ClassLoader>(); final Collection<ClassLoader> classLoaders = (Collection<ClassLoader>) configValues .get(AvailableSettings.CLASSLOADERS); if (classLoaders != null) { for (ClassLoader classLoader : classLoaders) { providedClassLoaders.add(classLoader); } } addIfSet(providedClassLoaders, AvailableSettings.APP_CLASSLOADER, configValues); addIfSet(providedClassLoaders, AvailableSettings.RESOURCES_CLASSLOADER, configValues); addIfSet(providedClassLoaders, AvailableSettings.HIBERNATE_CLASSLOADER, configValues); addIfSet(providedClassLoaders, AvailableSettings.ENVIRONMENT_CLASSLOADER, configValues); if (providedClassLoaders.isEmpty()) { LOG.debugf("Incoming config yielded no classloaders; adding standard SE ones"); final ClassLoader tccl = locateTCCL(); if (tccl != null) { providedClassLoaders.add(tccl); } providedClassLoaders.add(ClassLoaderServiceExt.class.getClassLoader()); } return new ClassLoaderServiceExt(providedClassLoaders); }
From source file:org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.java
License:Apache License
/** * 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})//w w w. j a va2 s .c o m * @param resourceLoader the ResourceLoader to load application classes from */ public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) { getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(Environment.DATASOURCE, dataSource); } getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader())); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }