List of usage examples for org.hibernate MultiTenancyStrategy DISCRIMINATOR
MultiTenancyStrategy DISCRIMINATOR
To view the source code for org.hibernate MultiTenancyStrategy DISCRIMINATOR.
Click Source Link
From source file:org.ameba.samples.tenancy.TenancySampleApplication.java
License:Apache License
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);//from w w w . ja v a2 s. c o m 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(); }