/** * Set a {@link MultiTenantConnectionProvider} to be passed on to the SessionFactory. * @since 4.3 * @see AvailableSettings#MULTI_TENANT_CONNECTION_PROVIDER */ public LocalSessionFactoryBuilder setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider) { getProperties().put(AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); return this; }
/** * Set the Hibernate {@link RegionFactory} to use for the SessionFactory. * Allows for using a Spring-managed {@code RegionFactory} instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @since 5.1 * @see AvailableSettings#CACHE_REGION_FACTORY */ public LocalSessionFactoryBuilder setCacheRegionFactory(RegionFactory cacheRegionFactory) { getProperties().put(AvailableSettings.CACHE_REGION_FACTORY, cacheRegionFactory); return this; }
/** * Overridden to reliably pass a {@link CurrentTenantIdentifierResolver} to the SessionFactory. * @since 4.3.2 * @see AvailableSettings#MULTI_TENANT_IDENTIFIER_RESOLVER */ @Override public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { getProperties().put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver); super.setCurrentTenantIdentifierResolver(currentTenantIdentifierResolver); }
/** * Set the Hibernate {@link RegionFactory} to use for the SessionFactory. * Allows for using a Spring-managed {@code RegionFactory} instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @since 5.1 * @see AvailableSettings#CACHE_REGION_FACTORY */ public LocalSessionFactoryBuilder setCacheRegionFactory(RegionFactory cacheRegionFactory) { getProperties().put(AvailableSettings.CACHE_REGION_FACTORY, cacheRegionFactory); return this; }
/** * Set a Hibernate {@link org.hibernate.resource.beans.container.spi.BeanContainer} * for the given Spring {@link ConfigurableListableBeanFactory}. * <p>Note: Bean container integration requires Hibernate 5.3 or higher. * It enables autowiring of Hibernate attribute converters and entity listeners. * @since 5.1 * @see SpringBeanContainer * @see AvailableSettings#BEAN_CONTAINER */ public LocalSessionFactoryBuilder setBeanContainer(ConfigurableListableBeanFactory beanFactory) { getProperties().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory)); return this; }
/** * Set a {@link MultiTenantConnectionProvider} to be passed on to the SessionFactory. * @since 4.3 * @see AvailableSettings#MULTI_TENANT_CONNECTION_PROVIDER */ public LocalSessionFactoryBuilder setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider) { getProperties().put(AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); return this; }
getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(AvailableSettings.DATASOURCE, dataSource); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD"); getProperties().put("hibernate.connection.release_mode", "ON_CLOSE"); getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader())); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of EntityManagerFactory proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("getProperties")) { return getProperties(); } else if (method.getName().equals("getWrappedObject")) { // Call coming in through InfrastructureProxy interface... return getSessionFactory(); } // Regular delegation to the target SessionFactory, // enforcing its full initialization... return method.invoke(getSessionFactory(), args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
/** * Overridden to reliably pass a {@link CurrentTenantIdentifierResolver} to the SessionFactory. * @since 4.3.2 * @see AvailableSettings#MULTI_TENANT_IDENTIFIER_RESOLVER */ @Override public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver) { getProperties().put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver); super.setCurrentTenantIdentifierResolver(currentTenantIdentifierResolver); }
/** * Set a Hibernate {@link org.hibernate.resource.beans.container.spi.BeanContainer} * for the given Spring {@link ConfigurableListableBeanFactory}. * <p>Note: Bean container integration requires Hibernate 5.3 or higher. * It enables autowiring of Hibernate attribute converters and entity listeners. * @since 5.1 * @see SpringBeanContainer * @see AvailableSettings#BEAN_CONTAINER */ public LocalSessionFactoryBuilder setBeanContainer(ConfigurableListableBeanFactory beanFactory) { getProperties().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory)); return this; }
boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader()); if (webspherePresent) { getProperties().put(AvailableSettings.JTA_PLATFORM, "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform"); "Can only apply JtaTransactionManager which has a TransactionManager reference set"); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(), jtaTm.getTransactionSynchronizationRegistry())); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null)); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT"); getProperties().put("hibernate.connection.release_mode", "AFTER_STATEMENT");
getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(AvailableSettings.DATASOURCE, dataSource); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD"); getProperties().put("hibernate.connection.release_mode", "ON_CLOSE"); getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader())); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of EntityManagerFactory proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("getProperties")) { return getProperties(); } else if (method.getName().equals("getWrappedObject")) { // Call coming in through InfrastructureProxy interface... return getSessionFactory(); } // Regular delegation to the target SessionFactory, // enforcing its full initialization... return method.invoke(getSessionFactory(), args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader()); if (webspherePresent) { getProperties().put(AvailableSettings.JTA_PLATFORM, "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform"); "Can only apply JtaTransactionManager which has a TransactionManager reference set"); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(), jtaTm.getTransactionSynchronizationRegistry())); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null)); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT"); getProperties().put("hibernate.connection.release_mode", "AFTER_STATEMENT");
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (method.getName().equals("equals")) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (method.getName().equals("hashCode")) { // Use hashCode of EntityManagerFactory proxy. return System.identityHashCode(proxy); } else if (method.getName().equals("getProperties")) { return getProperties(); } else if (method.getName().equals("getWrappedObject")) { // Call coming in through InfrastructureProxy interface... return getSessionFactory(); } // Regular delegation to the target SessionFactory, // enforcing its full initialization... return method.invoke(getSessionFactory(), args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader()); if (webspherePresent) { getProperties().put(AvailableSettings.JTA_PLATFORM, "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform"); "Can only apply JtaTransactionManager which has a TransactionManager reference set"); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(), jtaTm.getTransactionSynchronizationRegistry())); getProperties().put(AvailableSettings.JTA_PLATFORM, new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null)); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT"); getProperties().put("hibernate.connection.release_mode", "AFTER_STATEMENT");
@Override protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) { Properties properties = sfb.getProperties(); sfb.registerTypeOverride(createZonalTimestampType(properties)); return super.buildSessionFactory(sfb); }
getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName()); if (dataSource != null) { getProperties().put(AvailableSettings.DATASOURCE, dataSource); getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD"); getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader())); this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);