List of usage examples for org.hibernate.cfg AvailableSettings APP_CLASSLOADER
String APP_CLASSLOADER
To view the source code for org.hibernate.cfg AvailableSettings APP_CLASSLOADER.
Click Source Link
From source file:org.babyfish.springframework.orm.hibernate.LocalXSessionFactoryBuilder.java
License:Open Source 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})//from w w w .j a v a2 s . c o m * @param resourceLoader the ResourceLoader to load application classes from */ @SuppressWarnings("deprecation") public LocalXSessionFactoryBuilder(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.APP_CLASSLOADER, resourceLoader.getClassLoader()); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }
From source file:org.babyfish.springframework.orm.hibernate.LocalXSessionFactoryBuilder.java
License:Open Source License
/** * Build the {@code SessionFactory}.//w ww. j a va 2s. co m */ @Override @SuppressWarnings("deprecation") public XSessionFactory buildSessionFactory() throws HibernateException { ClassLoader appClassLoader = (ClassLoader) getProperties().get(AvailableSettings.APP_CLASSLOADER); Thread currentThread = Thread.currentThread(); ClassLoader threadContextClassLoader = currentThread.getContextClassLoader(); boolean overrideClassLoader = (appClassLoader != null && !appClassLoader.equals(threadContextClassLoader)); if (overrideClassLoader) { currentThread.setContextClassLoader(appClassLoader); } try { return super.buildSessionFactory(); } finally { if (overrideClassLoader) { currentThread.setContextClassLoader(threadContextClassLoader); } } }
From source file:org.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.java
License:Apache License
@Override public SessionFactory buildSessionFactory() throws HibernateException { // set the class loader to load Groovy classes // work around for HHH-2624 Map<String, Type> empty = new HashMap<String, Type>(); addFilterDefinition(new FilterDefinition("dynamicFilterEnabler", "1=1", empty)); SessionFactory sessionFactory = null; ClassLoader appClassLoader = (ClassLoader) getProperties().get(AvailableSettings.APP_CLASSLOADER); Thread currentThread = Thread.currentThread(); ClassLoader threadContextClassLoader = currentThread.getContextClassLoader(); boolean overrideClassLoader = (appClassLoader != null && !appClassLoader.equals(threadContextClassLoader)); if (overrideClassLoader) { currentThread.setContextClassLoader(appClassLoader); }// w w w . j a va2 s . co m try { ConfigurationHelper.resolvePlaceHolders(getProperties()); EventListenerIntegrator eventListenerIntegrator = new EventListenerIntegrator(hibernateEventListeners, eventListeners); BootstrapServiceRegistry bootstrapServiceRegistry = new BootstrapServiceRegistryBuilder() .with(eventListenerIntegrator).build(); setSessionFactoryObserver(new SessionFactoryObserver() { private static final long serialVersionUID = 1; public void sessionFactoryCreated(SessionFactory factory) { } public void sessionFactoryClosed(SessionFactory factory) { ((ServiceRegistryImplementor) serviceRegistry).destroy(); } }); StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry).applySettings(getProperties()); sessionFactory = super.buildSessionFactory(standardServiceRegistryBuilder.build()); serviceRegistry = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry(); } finally { if (overrideClassLoader) { currentThread.setContextClassLoader(threadContextClassLoader); } } return sessionFactory; }
From source file:org.jboss.as.jpa.hibernate.HibernatePersistenceProviderAdaptor.java
License:Open Source License
@Override public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { properties.put(Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); properties.put(org.hibernate.ejb.AvailableSettings.SCANNER, "org.jboss.as.jpa.hibernate.HibernateAnnotationScanner"); properties.put(AvailableSettings.APP_CLASSLOADER, pu.getClassLoader()); properties.put(AvailableSettings.JTA_PLATFORM, new JBossAppServerJtaPlatform()); }
From source file:org.jboss.as.jpa.hibernate4.HibernatePersistenceProviderAdaptor.java
License:Open Source License
@SuppressWarnings("deprecation") @Override/*from w w w . java2 s. c o m*/ public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { putPropertyIfAbsent(pu, properties, AvailableSettings.JPAQL_STRICT_COMPLIANCE, "true"); // JIPI-24 ignore jpql aliases case putPropertyIfAbsent(pu, properties, Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); putPropertyIfAbsent(pu, properties, org.hibernate.ejb.AvailableSettings.SCANNER, HibernateArchiveScanner.class.getName()); properties.put(AvailableSettings.APP_CLASSLOADER, pu.getClassLoader()); putPropertyIfAbsent(pu, properties, AvailableSettings.JTA_PLATFORM, new JBossAppServerJtaPlatform(jtaManager)); putPropertyIfAbsent(pu, properties, org.hibernate.ejb.AvailableSettings.ENTITY_MANAGER_FACTORY_NAME, pu.getScopedPersistenceUnitName()); putPropertyIfAbsent(pu, properties, AvailableSettings.SESSION_FACTORY_NAME, pu.getScopedPersistenceUnitName()); if (!pu.getProperties().containsKey(AvailableSettings.SESSION_FACTORY_NAME)) { putPropertyIfAbsent(pu, properties, AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI, Boolean.FALSE); } }
From source file:org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.java
License:Apache License
@SuppressWarnings("deprecation") @Override/* w ww . j a va2s . c o m*/ public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { putPropertyIfAbsent(pu, properties, AvailableSettings.JPAQL_STRICT_COMPLIANCE, "true"); // JIPI-24 ignore jpql aliases case putPropertyIfAbsent(pu, properties, AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); putPropertyIfAbsent(pu, properties, AvailableSettings.KEYWORD_AUTO_QUOTING_ENABLED, "false"); putPropertyIfAbsent(pu, properties, AvailableSettings.IMPLICIT_NAMING_STRATEGY, NAMING_STRATEGY_JPA_COMPLIANT_IMPL); putPropertyIfAbsent(pu, properties, AvailableSettings.SCANNER, HibernateArchiveScanner.class); properties.put(AvailableSettings.APP_CLASSLOADER, pu.getClassLoader()); putPropertyIfAbsent(pu, properties, AvailableSettings.JTA_PLATFORM, new JBossAppServerJtaPlatform(jtaManager)); putPropertyIfAbsent(pu, properties, org.hibernate.ejb.AvailableSettings.ENTITY_MANAGER_FACTORY_NAME, pu.getScopedPersistenceUnitName()); putPropertyIfAbsent(pu, properties, AvailableSettings.SESSION_FACTORY_NAME, pu.getScopedPersistenceUnitName()); if (!pu.getProperties().containsKey(AvailableSettings.SESSION_FACTORY_NAME)) { putPropertyIfAbsent(pu, properties, AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI, Boolean.FALSE); } }
From source file:org.lightmare.jpa.hibernate.boot.registry.classloading.internal.ClassLoaderServiceExt.java
License:Open Source License
/** * No longer used/supported!/*from www.ja v a 2s . c o 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.hibernate4.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 ww . java 2 s . c o m * @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); }
From source file:org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.java
License:Apache License
/** * Build the {@code SessionFactory}.//from w w w . j a v a2 s.c o m */ @Override @SuppressWarnings("deprecation") public SessionFactory buildSessionFactory() throws HibernateException { ClassLoader appClassLoader = (ClassLoader) getProperties().get(AvailableSettings.APP_CLASSLOADER); Thread currentThread = Thread.currentThread(); ClassLoader threadContextClassLoader = currentThread.getContextClassLoader(); boolean overrideClassLoader = (appClassLoader != null && !appClassLoader.equals(threadContextClassLoader)); if (overrideClassLoader) { currentThread.setContextClassLoader(appClassLoader); } try { return super.buildSessionFactory(); } finally { if (overrideClassLoader) { currentThread.setContextClassLoader(threadContextClassLoader); } } }
From source file:org.springframework.orm.hibernate43.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})/*from w w w.ja va 2s. co 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.APP_CLASSLOADER, resourceLoader.getClassLoader()); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); }