本文整理汇总了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java LocalContainerEntityManagerFactoryBean.afterPropertiesSet方法的具体用法?Java LocalContainerEntityManagerFactoryBean.afterPropertiesSet怎么用?Java LocalContainerEntityManagerFactoryBean.afterPropertiesSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
的用法示例。
在下文中一共展示了LocalContainerEntityManagerFactoryBean.afterPropertiesSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
emf.setPackagesToScan("io.github.azanx.shopping_list.domain");
emf.setPersistenceUnitName("spring-jpa-unit");
emf.setJpaVendorAdapter(getHibernateAdapter());
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.dialect", env.getProperty("hibernate.dialect"));
jpaProperties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
jpaProperties.put("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
jpaProperties.put("hibernate.format_sql", env.getProperty("hibernate.format_sql"));
emf.setJpaProperties(jpaProperties);
emf.afterPropertiesSet();
return emf.getObject();
}
示例2: newEntityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
public static EntityManagerFactory newEntityManagerFactory(DataSource dataSource, Class<?> ... entityPackages){
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
BasicDataSource basicDataSource = (BasicDataSource)dataSource;
Database jpaDatabase = DatabaseType.findTypeByJdbcUrl(basicDataSource.getUrl()).getJpaDatabase();
vendorAdapter.setDatabase(jpaDatabase);
HashMap<String, Object> properties = new HashMap<String, Object>();
//properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
//import @Entity classes
factory.setPackagesToScan(Arrays.stream(entityPackages).map(thing -> thing.getPackage().getName()).toArray(String[]::new));
//factory.setPersistenceUnitName("jproject");
factory.setDataSource(dataSource);
factory.setJpaPropertyMap(properties);
factory.afterPropertiesSet();
return factory.getObject();
}
示例3: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean(EntityManagerFactoryBeanName)
@Primary
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
@Qualifier(DataSourceBeanName) DataSource dataSource,
@Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect());
entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName());
entityManagerFactoryBean.setPersistenceUnitName("mysqlsource1");
entityManagerFactoryBean.afterPropertiesSet();
return entityManagerFactoryBean;
}
示例4: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
// JPA settings
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
// vendorAdapter.setGenerateDdl(true);
// vendorAdapter.setShowSql(true);
vendorAdapter.setDatabase(Database.MYSQL);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("org.amv.access.model");
factory.setDataSource(dataSource);
factory.setJpaProperties(jpaProperties());
factory.afterPropertiesSet();
return factory;
}
示例5: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
logger.debug("Configuring EntityManager");
LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();
lcemfb.setPersistenceProvider(new HibernatePersistenceProvider());
lcemfb.setPersistenceUnitName("persistenceUnit");
lcemfb.setDataSource(dataSource());
lcemfb.setJpaDialect(new HibernateJpaDialect());
lcemfb.setJpaVendorAdapter(jpaVendorAdapter());
lcemfb.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.generate_statistics", false);
jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL));
lcemfb.setJpaProperties(jpaProperties);
lcemfb.setPackagesToScan("cn.org.once.cstack.model");
lcemfb.afterPropertiesSet();
return lcemfb.getObject();
}
示例6: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
logger.debug("Configuring EntityManager");
LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();
lcemfb.setPersistenceProvider(new HibernatePersistenceProvider());
lcemfb.setPersistenceUnitName("persistenceUnit");
lcemfb.setDataSource(dataSource());
lcemfb.setJpaDialect(new HibernateJpaDialect());
lcemfb.setJpaVendorAdapter(jpaVendorAdapter());
lcemfb.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.generate_statistics", true);
jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL));
lcemfb.setJpaProperties(jpaProperties);
lcemfb.setPackagesToScan("cn.org.once.cstack.model");
lcemfb.afterPropertiesSet();
return lcemfb.getObject();
}
示例7: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
// vendorAdapter.setGenerateDdl(true); // Crea la tabella e le colonne quando non esistono
vendorAdapter.setShowSql(config.getShowSql());
vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
List<String> packages = config.getDbEntityPackages();
packages.add("net.yadaframework.persistence.entity");
packages.add("net.yadaframework.security.persistence.entity");
packages.add("net.yadaframework.cms.persistence.entity");
packages.add("net.yadaframework.commerce.persistence.entity");
log.info("Scanning packages for entities: {}", StringUtils.join(packages, ","));
factory.setPackagesToScan(packages.toArray(new String[]{}));
factory.setDataSource(dataSource());
factory.afterPropertiesSet();
return factory.getObject();
}
示例8: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
final Database database = Database.valueOf(vendor.toUpperCase());
/*
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setShowSql(showSql);
vendorAdapter.setGenerateDdl(showDdl);
vendorAdapter.setDatabase(database);
*/
final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setPersistenceUnitName("CCRI_PU");
// factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("uk.nhs.careconnect.ri.entity");
factory.setDataSource(dataSource);
factory.setPersistenceProvider(new HibernatePersistenceProvider());
factory.setJpaProperties(jpaProperties());
factory.afterPropertiesSet();
return factory.getObject();
}
示例9: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory(DataSource dataSource, Properties dbProperties)
throws SQLException {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
String dialect = dbProperties.getProperty("hibernateDialect");
factory.getJpaPropertyMap().put("hibernate.dialect", dialect);
factory.setPackagesToScan("hei2017.entity");
factory.setDataSource(dataSource);
factory.afterPropertiesSet();
return factory.getObject();
}
示例10: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan("de.adesso.jenkinshue.entity");
lef.setJpaProperties(dataSourceConfig.getJpaProperties());
lef.afterPropertiesSet();
return lef;
}
示例11: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean(EntityManagerFactoryBeanName)
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
@Qualifier(DataSourceBeanName) DataSource dataSource,
@Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect());
entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName());
entityManagerFactoryBean.setPersistenceUnitName("mysqlsource2");
entityManagerFactoryBean.afterPropertiesSet();
return entityManagerFactoryBean;
}
示例12: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* Create new EntityManagerFactory
*
* @param dataSource the data source
* @param hibernateProperties the hibernate properties
* @return the entity manager factory
*/
@Bean
public EntityManagerFactory entityManagerFactory(final DataSource dataSource, final Properties hibernateProperties) {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan(entitymanagerPackagesToScan);
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(hibernateProperties);
em.setPersistenceUnitName("nestedbird");
em.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
em.afterPropertiesSet();
return em.getObject();
}
示例13: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory(JpaVendorAdapter jpaVendorAdapter, DataSource dataSource) {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(jpaVendorAdapter);
factory.setPackagesToScan("todolist.entities");
factory.setDataSource(dataSource);
factory.afterPropertiesSet();
return factory.getObject();
}
示例14: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory(JpaVendorAdapter jpaVendorAdapter, DataSource dataSource) {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(jpaVendorAdapter);
factory.setPackagesToScan("hello.entities");
factory.setDataSource(dataSource);
factory.afterPropertiesSet();
return factory.getObject();
}
示例15: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.POSTGRESQL);
vendorAdapter.setGenerateDdl(generateDDL);
vendorAdapter.setShowSql(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("ro.dutylabs.mpp.core.model");
factory.setDataSource(dataSource());
factory.afterPropertiesSet();
return factory.getObject();
}