• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MultiTenancyStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.MultiTenancyStrategy的典型用法代码示例。如果您正苦于以下问题:Java MultiTenancyStrategy类的具体用法?Java MultiTenancyStrategy怎么用?Java MultiTenancyStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MultiTenancyStrategy类属于org.hibernate包,在下文中一共展示了MultiTenancyStrategy类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
    DataSource dataSource,
    MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
    CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:21,代码来源:DatabaseConfiguration.java


示例2: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
    DataSource dataSource,
    MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
    CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl,
    LocalValidatorFactoryBean localValidatorFactoryBean) {

    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties.put(MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties.put(MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);
    properties.put(JPA_VALIDATION_FACTORY, localValidatorFactoryBean);

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
 
开发者ID:xm-online,项目名称:xm-ms-balance,代码行数:22,代码来源:DatabaseConfiguration.java


示例3: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
    MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
    CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
 
开发者ID:xm-online,项目名称:xm-ms-dashboard,代码行数:20,代码来源:DatabaseConfiguration.java


示例4: getJdbcConnectionAccess

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Override
public JdbcConnectionAccess getJdbcConnectionAccess() {
	if ( jdbcConnectionAccess == null ) {
		if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
			jdbcConnectionAccess = new NonContextualJdbcConnectionAccess(
					getEventListenerManager(),
					factory.getServiceRegistry().getService( ConnectionProvider.class )
			);
		}
		else {
			jdbcConnectionAccess = new ContextualJdbcConnectionAccess(
					getEventListenerManager(),
					factory.getServiceRegistry().getService( MultiTenantConnectionProvider.class )
			);
		}
	}
	return jdbcConnectionAccess;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:AbstractSessionImpl.java


示例5: buildLocalConnectionAccess

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
private JdbcConnectionAccess buildLocalConnectionAccess() {
	return new JdbcConnectionAccess() {
		@Override
		public Connection obtainConnection() throws SQLException {
			return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE
					? serviceRegistry.getService( ConnectionProvider.class ).getConnection()
					: serviceRegistry.getService( MultiTenantConnectionProvider.class ).getAnyConnection();
		}

		@Override
		public void releaseConnection(Connection connection) throws SQLException {
			if ( settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE ) {
				serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection );
			}
			else {
				serviceRegistry.getService( MultiTenantConnectionProvider.class ).releaseAnyConnection( connection );
			}
		}

		@Override
		public boolean supportsAggressiveRelease() {
			return false;
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:SessionFactoryImpl.java


示例6: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProvider,
                                                                   CurrentTenantIdentifierResolver tenantIdentifierResolver) {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan("com.mycompany.models");

    em.setJpaVendorAdapter(this.jpaVendorAdapter());

    final Map<String, Object> jpaProperties = new HashMap<>();
    jpaProperties.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    jpaProperties.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider);
    jpaProperties.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, tenantIdentifierResolver);
    jpaProperties.put(Environment.FORMAT_SQL, true);

    em.setJpaPropertyMap(jpaProperties);
    return em;
}
 
开发者ID:SAP,项目名称:cloud-s4-sdk-examples,代码行数:19,代码来源:HibernateConfig.java


示例7: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
    MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
    CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl) {
  Map<String, Object> properties = new HashMap<>();
  properties.putAll(jpaProperties.getHibernateProperties(dataSource));
  properties.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
  properties.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
  properties.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

  LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
  em.setDataSource(dataSource);
  em.setPackagesToScan("com.srai");
  em.setJpaVendorAdapter(jpaVendorAdapter());
  em.setJpaPropertyMap(properties);
  return em;
}
 
开发者ID:singram,项目名称:spring-boot-multitenant,代码行数:18,代码来源:HibernateConfig.java


示例8: entityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
                                                                   MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
                                                                   CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl,
                                                                   LocalValidatorFactoryBean localValidatorFactoryBean) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

    properties.put(JPA_VALIDATION_FACTORY, localValidatorFactoryBean);

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:23,代码来源:DatabaseConfiguration.java


示例9: buildJdbcConnectionAccess

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
private JdbcConnectionAccess buildJdbcConnectionAccess(Map configValues) {
	final MultiTenancyStrategy multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configValues );

	if ( MultiTenancyStrategy.NONE == multiTenancyStrategy ) {
		connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
		return new ConnectionProviderJdbcConnectionAccess( connectionProvider );
	}
	else {
		connectionProvider = null;
		final MultiTenantConnectionProvider multiTenantConnectionProvider = serviceRegistry.getService( MultiTenantConnectionProvider.class );
		return new MultiTenantConnectionProviderJdbcConnectionAccess( multiTenantConnectionProvider );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:JdbcServicesImpl.java


示例10: AbstractSessionImpl

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
protected AbstractSessionImpl(SessionFactoryImpl factory, String tenantIdentifier) {
	this.factory = factory;
	this.tenantIdentifier = tenantIdentifier;
	if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
		if ( tenantIdentifier != null ) {
			throw new HibernateException( "SessionFactory was not configured for multi-tenancy" );
		}
	}
	else {
		if ( tenantIdentifier == null ) {
			throw new HibernateException( "SessionFactory configured for multi-tenancy, but no tenant identifier specified" );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AbstractSessionImpl.java


示例11: createSessionFactoryBean

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
protected LocalSessionFactoryBean createSessionFactoryBean() {

		LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
		factoryBean.setDataSource(this.dataSourceConfig.dataSource());

		if (StringUtil.isEmpty(this.propertiesConfig.hibernateDialect())) {
			throw new IllegalStateException("hibernateDialect is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.DIALECT,
				this.propertiesConfig.hibernateDialect());

		if (!ArrayUtil.isEmpty(this.propertiesConfig.hibernateMappingLocations())) {
			factoryBean
					.setMappingLocations(this.propertiesConfig.hibernateMappingLocations());
		}

		// configure for multitenancy
		if (!(this.dataSourceConfig.dataSource() instanceof MultiTenantDataSource)) {
			throw new IllegalStateException("a MultiTenantDataSource is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.MULTI_TENANT,
				MultiTenancyStrategy.DATABASE.toString());
		factoryBean.setMultiTenantConnectionProvider(
				new MultiTenantConnectionProviderImpl((MultiTenantDataSource) this.dataSourceConfig.dataSource()));
		factoryBean.setCurrentTenantIdentifierResolver(
				new CurrentTenantIdentifierResolverImpl(contextConfig.tenantResolver()));

		// update guard
		factoryBean.setEntityInterceptor(new MultiTenantEntityInterceptor(contextConfig.tenantResolver()));

		return factoryBean;

	}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:36,代码来源:HibernateConfig.java


示例12: customEntityManagerFactory

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
public
@Bean
EntityManagerFactory customEntityManagerFactory(DataSource dataSource) {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false); // turn off with Discriminator strategy so far!
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(TenancySampleApplication.class.getPackage().getName());
    factory.setDataSource(dataSource);
    factory.getJpaPropertyMap().put(Environment.DIALECT, PostgreSQL9Dialect.class.getName());
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT, MultiTenancyStrategy.DISCRIMINATOR);
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, new TenantHolder());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
开发者ID:spring-labs,项目名称:tenancy-sample,代码行数:16,代码来源:TenancySampleApplication.java


示例13: buildLocalConnectionAccess

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
private JdbcConnectionAccess buildLocalConnectionAccess() {
	return new JdbcConnectionAccess() {
		@Override
		public Connection obtainConnection() throws SQLException {
			return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE ? serviceRegistry
					.getService(ConnectionProvider.class).getConnection()
					: serviceRegistry.getService(
							MultiTenantConnectionProvider.class)
							.getAnyConnection();
		}

		@Override
		public void releaseConnection(Connection connection)
				throws SQLException {
			if (settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE) {
				serviceRegistry.getService(ConnectionProvider.class)
						.closeConnection(connection);
			} else {
				serviceRegistry.getService(
						MultiTenantConnectionProvider.class)
						.releaseAnyConnection(connection);
			}
		}

		@Override
		public boolean supportsAggressiveRelease() {
			return false;
		}
	};
}
 
开发者ID:Gary-zhouxianjun,项目名称:hibernate-dynamic-dialects,代码行数:31,代码来源:SessionFactoryImpl.java


示例14: getMultiTenancyStrategy

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
public MultiTenancyStrategy getMultiTenancyStrategy() {
	return multiTenancyStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Settings.java


示例15: setMultiTenancyStrategy

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
void setMultiTenancyStrategy(MultiTenancyStrategy multiTenancyStrategy) {
	this.multiTenancyStrategy = multiTenancyStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Settings.java


示例16: initiateService

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Override
@SuppressWarnings( {"unchecked"})
public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final MultiTenancyStrategy strategy = MultiTenancyStrategy.determineMultiTenancyStrategy(  configurationValues );
	if ( strategy == MultiTenancyStrategy.NONE || strategy == MultiTenancyStrategy.DISCRIMINATOR ) {
		// nothing to do, but given the separate hierarchies have to handle this here.
		return null;
	}

	final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER );
	if ( configValue == null ) {
		// if they also specified the data source *name*, then lets assume they want
		// DataSourceBasedMultiTenantConnectionProviderImpl
		final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE );
		if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) {
			return new DataSourceBasedMultiTenantConnectionProviderImpl();
		}

		return null;
	}

	if ( MultiTenantConnectionProvider.class.isInstance( configValue ) ) {
		return (MultiTenantConnectionProvider) configValue;
	}
	else {
		final Class<MultiTenantConnectionProvider> implClass;
		if ( Class.class.isInstance( configValue ) ) {
			implClass = (Class) configValue;
		}
		else {
			final String className = configValue.toString();
			final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
			try {
				implClass = classLoaderService.classForName( className );
			}
			catch (ClassLoadingException cle) {
				log.warn( "Unable to locate specified class [" + className + "]", cle );
				throw new ServiceException( "Unable to locate specified multi-tenant connection provider [" + className + "]" );
			}
		}

		try {
			return implClass.newInstance();
		}
		catch (Exception e) {
			log.warn( "Unable to instantiate specified class [" + implClass.getName() + "]", e );
			throw new ServiceException( "Unable to instantiate specified multi-tenant connection provider [" + implClass.getName() + "]" );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:MultiTenantConnectionProviderInitiator.java


示例17: initiateService

import org.hibernate.MultiTenancyStrategy; //导入依赖的package包/类
@Override
public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final MultiTenancyStrategy strategy = MultiTenancyStrategy.determineMultiTenancyStrategy(  configurationValues );
	if ( strategy == MultiTenancyStrategy.DATABASE || strategy == MultiTenancyStrategy.SCHEMA ) {
		// nothing to do, but given the separate hierarchies have to handle this here.
		return null;
	}

	final StrategySelector strategySelector = registry.getService( StrategySelector.class );

	ConnectionProvider connectionProvider = null;
	final String providerName = getConfiguredConnectionProviderName( configurationValues );
	if ( providerName != null ) {
		connectionProvider = instantiateExplicitConnectionProvider( providerName, strategySelector );
	}
	else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
		connectionProvider = new DatasourceConnectionProviderImpl();
	}

	if ( connectionProvider == null ) {
		if ( c3p0ConfigDefined( configurationValues ) ) {
			connectionProvider = instantiateC3p0Provider( strategySelector );
		}
	}

	if ( connectionProvider == null ) {
		if ( proxoolConfigDefined( configurationValues ) ) {
			connectionProvider = instantiateProxoolProvider( strategySelector );
		}
	}

	if ( connectionProvider == null ) {
		if ( configurationValues.get( Environment.URL ) != null ) {
			connectionProvider = new DriverManagerConnectionProviderImpl();
		}
	}

	if ( connectionProvider == null ) {
		LOG.noAppropriateConnectionProvider();
		connectionProvider = new UserSuppliedConnectionProviderImpl();
	}


	final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
	if ( injectionData != null && injectionData.size() > 0 ) {
		final ConnectionProvider theConnectionProvider = connectionProvider;
		new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
				connectionProvider,
				new BeanInfoHelper.BeanInfoDelegate() {
					public void processBeanInfo(BeanInfo beanInfo) throws Exception {
						final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
						for ( PropertyDescriptor descriptor : descriptors ) {
							final String propertyName = descriptor.getName();
							if ( injectionData.containsKey( propertyName ) ) {
								final Method method = descriptor.getWriteMethod();
								method.invoke(
										theConnectionProvider,
										injectionData.get( propertyName )
								);
							}
						}
					}
				}
		);
	}

	return connectionProvider;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:69,代码来源:ConnectionProviderInitiator.java



注:本文中的org.hibernate.MultiTenancyStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SelectionSpec类代码示例发布时间:2022-05-22
下一篇:
Java NormalOcclusionTest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap