本文整理汇总了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setJpaVendorAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java LocalContainerEntityManagerFactoryBean.setJpaVendorAdapter方法的具体用法?Java LocalContainerEntityManagerFactoryBean.setJpaVendorAdapter怎么用?Java LocalContainerEntityManagerFactoryBean.setJpaVendorAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
的用法示例。
在下文中一共展示了LocalContainerEntityManagerFactoryBean.setJpaVendorAdapter方法的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: 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;
}
示例3: entityManagerFactoryBean
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* EntityManager configuration.
*/
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(getDatasource());
em.setJpaDialect(jpaDialect());
em.setPackagesToScan(entityManagerProperties.getPackagesToScan());
em.setPersistenceUnitName(eclipseLinkProperties.getPersistenceUnitName());
final DatabasePlatform dp = new MySQLPlatform();
em.setJpaVendorAdapter(getEclipseLinkJpaVendorAdapter());
//following code will be used for static weaving. Uncomment when creating war.
final Map<String, String> propMap = new HashMap<String, String>();
propMap.put("eclipselink.weaving", eclipseLinkProperties.getWeaving());
em.setJpaPropertyMap(propMap);
// em.setLoadTimeWeaver(loadTimeWeaver()); //comment this when using static weaving. Mostly in development environment inside eclipse
return em;
}
示例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: entityManagerFactory1
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
@Qualifier("one")
public FactoryBean<EntityManagerFactory> entityManagerFactory1(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;
}
示例6: getEntityManager
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean(name="entityManagerFactory")
public LocalContainerEntityManagerFactoryBean getEntityManager(){
// класса фабрики реализующей интерфейс FactoryBean<EntityManagerFactory>
LocalContainerEntityManagerFactoryBean factory =
new LocalContainerEntityManagerFactoryBean();
// источник подключения
factory.setDataSource(getDataSource());
// адаптера для конкретной реализации JPA,
// указывает, какая библиотека будет использоваться в качестве постовщика
factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
// указание пакета в котором находятся классы-сущности
factory.setPackagesToScan("spring.domain");
//создание свойств для настройки Hibernate
Properties jpaProperties = new Properties();
// диалект базы данных,необходимо для генерации запросов Hibernate к БД
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.SQLiteDialect");
// максимальная глубины связи(будет рассмотрено в след. уроке)
jpaProperties.put("hibernate.max_fetch_depth", 3);
// максимальное число строк, возвращаемых за один запрос из БД
jpaProperties.put("hibernate.jdbc.fetch_size", 50);
// максимальное число запросов при использовании пакетных операций
jpaProperties.put("hibernate.jdbc.batch_size", 10);
// включает логгирование
jpaProperties.put("hibernate.show_sql", true);
factory.setJpaProperties(jpaProperties);
return factory;
}
示例7: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* Creates the entity manager factory.
*
* @param dataSource the data source to use
* @return entity manager factory
*/
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
JpaVendorAdapter jpaVendorAdapter = createJpaVendorAdapter();
entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
Map<String, String> jpaPropertyMap = getJpaPropertyMap();
entityManagerFactoryBean.setJpaPropertyMap(jpaPropertyMap);
getMappingResources().ifPresent(entityManagerFactoryBean::setMappingResources);
getPackagesToScan().ifPresent(entityManagerFactoryBean::setPackagesToScan);
// https://hibernate.atlassian.net/browse/HHH-5303#comment-44439
entityManagerFactoryBean.setSharedCacheMode(ENABLE_SELECTIVE);
customizeEntityManagerFactoryBean(entityManagerFactoryBean);
return entityManagerFactoryBean;
}
示例8: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* Container managed JPA
* This bean replaces <code>persistence.xml</code>
* Defines packages to scan with {@link javax.persistence.Entity} annotation
* @return Entity manager factory
*/
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
JpaVendorAdapter jpaVendorAdapter){
LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
emfb.setDataSource(dataSource);
emfb.setJpaVendorAdapter(jpaVendorAdapter);
emfb.setPackagesToScan(PACKAGE_TO_SCAN_ENTITIES);
return emfb;
}
示例9: 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("com.fetoxdevelopments.wormboard.domain");
return lef;
}
示例10: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setDataSource(dataSource());
factory.setJpaVendorAdapter(jpaVendorAdapter());
factory.setPackagesToScan("com.namics.oss.spring.support.i18n.dao.jpa");
factory.setPersistenceUnitName("jpaPersistenceUnit");
factory.setJpaProperties(jpaProperties());
factory.setJpaDialect(new HibernateJpaDialect());
return factory;
}
示例11: 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();
}
示例12: 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.setDatabase(Database.H2);
emf.setJpaVendorAdapter(va);
emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName());
emf.setPersistenceUnitName("test");
return emf;
}
示例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("hello.entities");
factory.setDataSource(dataSource);
factory.afterPropertiesSet();
return factory.getObject();
}
示例14: entityManagerFactory
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException {
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(dataSource());
factoryBean.setPackagesToScan(new String[] { "com.docker.atsea.model" });
factoryBean.setJpaVendorAdapter(jpaVendorAdapter());
factoryBean.setJpaProperties(jpaProperties());
return factoryBean;
}
示例15: 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;
}