本文整理汇总了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java LocalContainerEntityManagerFactoryBean.setDataSource方法的具体用法?Java LocalContainerEntityManagerFactoryBean.setDataSource怎么用?Java LocalContainerEntityManagerFactoryBean.setDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
的用法示例。
在下文中一共展示了LocalContainerEntityManagerFactoryBean.setDataSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("com.tickets.business.entities");
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
em.setJpaProperties(hibernateProperties);
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
return em;
}
示例2: 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();
}
示例3: orderEntityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
LocalContainerEntityManagerFactoryBean orderEntityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(orderDataSource());
factoryBean.setJpaVendorAdapter(vendorAdapter);
factoryBean.setPackagesToScan(OrderConfig.class.getPackage().getName());
return factoryBean;
}
示例4: getLocalContainerEntityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean getLocalContainerEntityManagerFactoryBean() {
LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaProperties(hibernateProperties());
bean.setPackagesToScan(TestEntity.class.getPackage().getName());
bean.setDataSource(testDataSource());
bean.setPersistenceUnitName("TEST");
return bean;
}
示例5: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setPackagesToScan(Constants.BASE_PACKAGE);
emf.setPersistenceProvider(new HibernatePersistenceProvider());
emf.setJpaProperties(jpaProperties());
return emf;
}
示例6: newHibernateEntityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* New entity manager factory bean.
*
* @param config the config
* @param jpaProperties the jpa properties
* @return the local container entity manager factory bean
*/
public static LocalContainerEntityManagerFactoryBean newHibernateEntityManagerFactoryBean(final JpaConfigDataHolder config,
final AbstractJpaProperties jpaProperties) {
final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaVendorAdapter(config.getJpaVendorAdapter());
if (StringUtils.isNotBlank(config.getPersistenceUnitName())) {
bean.setPersistenceUnitName(config.getPersistenceUnitName());
}
bean.setPackagesToScan(config.getPackagesToScan());
bean.setDataSource(config.getDataSource());
final Properties properties = new Properties();
properties.put("hibernate.dialect", jpaProperties.getDialect());
properties.put("hibernate.hbm2ddl.auto", jpaProperties.getDdlAuto());
properties.put("hibernate.jdbc.batch_size", jpaProperties.getBatchSize());
if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) {
properties.put("hibernate.default_catalog", jpaProperties.getDefaultCatalog());
}
if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) {
properties.put("hibernate.default_schema", jpaProperties.getDefaultSchema());
}
bean.setJpaProperties(properties);
bean.getJpaPropertyMap().put("hibernate.enable_lazy_load_no_trans", Boolean.TRUE);
return bean;
}
示例7: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setPackagesToScan(Post.class.getPackage().getName());
emf.setPersistenceProvider(new HibernatePersistenceProvider());
emf.setJpaProperties(jpaProperties());
return emf;
}
示例8: 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();
}
示例9: getLocalContainerEntityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean getLocalContainerEntityManagerFactoryBean() {
LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaProperties(hibernateProperties());
bean.setPackagesToScan(MovieEntity.class.getPackage().getName());
bean.setDataSource(testDataSource());
bean.setPersistenceUnitName("TEST");
return bean;
}
示例10: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("org.restaurant.repository.model");
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
return em;
}
示例11: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
va.setShowSql(true);
emf.setJpaVendorAdapter(va);
emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName());
emf.setPersistenceUnitName("test");
emf.getJpaPropertyMap().put("hibernate.jdbc.batch_size", 5);
return emf;
}
示例12: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public FactoryBean<EntityManagerFactory> entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
va.setShowSql(true);
emf.setJpaVendorAdapter(va);
emf.setPackagesToScan(TestJpaDomain1.class.getPackage().getName());
return emf;
}
示例13: entityManagerFactory1
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
@Primary
public FactoryBean<EntityManagerFactory> entityManagerFactory1(@Qualifier("one") DataSource dataSource) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
va.setShowSql(true);
emf.setJpaVendorAdapter(va);
emf.setPackagesToScan(TestJpaDomain1.class.getPackage().getName());
emf.setPersistenceUnitName("one");
return emf;
}
示例14: entityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
Map<String, Object> properties = new HashMap<>();
// properties.put("javax.persistence.schema-generation.database.action", "none"); // 没有update选项,只有:none、create、drop-and-create、drop,不满足开发需求
// properties.put("hibernate.hbm2ddl.auto", "update"); // 使用adapter.setGenerateDdl(true),避免拼写错误;
properties.put("hibernate.ejb.use_class_enhancer", "true");
properties.put("hibernate.search.default.directory_provider", "filesystem");
properties.put("hibernate.search.lucene_version", "5.3.1"); // 避免控制台警告,默认使用LUCENE_CURRENT
properties.put("hibernate.search.default.indexBase", "../amanda/searchIndexes");
// properties.put("hibernate.show_sql", "true");
// properties.put("hibernate.format_sql", "true");
properties.put("hibernate.use_sql_comments", "true");
properties.put("hibernate.physical_naming_strategy", "com.timeyang.amanda.core.jpa.naming.PhysicalNamingStrategyImpl");
LocalContainerEntityManagerFactoryBean factory =
new LocalContainerEntityManagerFactoryBean();
factory.setDataSource(this.dataSource);
factory.setJpaVendorAdapter(jpaVendorAdapter());
factory.setPackagesToScan(AmandaApplication.class.getPackage().getName());
factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
factory.setValidationMode(ValidationMode.NONE);
factory.setLoadTimeWeaver(this.loadTimeWeaver()); // TODO: remove when SPR-10856 fixed
factory.setJpaPropertyMap(properties);
return factory;
}
示例15: getEntityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean getEntityManagerFactoryBean() {
final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(getJpaVendorAdapter());
factory.setPersistenceXmlLocation("classpath:META-INF/test-persistence.xml");
factory.setDataSource(getDataSource());
factory.setJpaProperties(getJpaProperties());
return factory;
}