本文整理汇总了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setValidationMode方法的典型用法代码示例。如果您正苦于以下问题:Java LocalContainerEntityManagerFactoryBean.setValidationMode方法的具体用法?Java LocalContainerEntityManagerFactoryBean.setValidationMode怎么用?Java LocalContainerEntityManagerFactoryBean.setValidationMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
的用法示例。
在下文中一共展示了LocalContainerEntityManagerFactoryBean.setValidationMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: configure
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //导入方法依赖的package包/类
/**
* Configure given bean using provided configuration settings
* @param emf Bean to configure
*/
public void configure(LocalContainerEntityManagerFactoryBean emf) {
if (dataContextId != null) {
emf.setPersistenceUnitName(dataContextId);
}
if (!entityPackages.isEmpty()) {
emf.setPackagesToScan(entityPackages.toArray(new String[0]));
}
if (validationMode != null) {
emf.setValidationMode(validationMode);
}
if (sharedCacheMode != null) {
emf.setSharedCacheMode(sharedCacheMode);
}
if (jpaProperties != null) {
emf.setJpaProperties(jpaProperties);
}
// ORM adapter
ORMPlatform orm = ormPlatform;
if (orm == null) {
// try to detect
try {
orm = ORMPlatform.detectFromClasspath();
} catch (IllegalStateException e) {
logger.warn("Ensure to declare ORM platfrom through property or persistence.xml", e);
}
}
if (orm != null) {
JpaVendorAdapter adapter = buildJpaVendorAdapter(orm);
if (adapter != null) {
emf.setJpaVendorAdapter(adapter);
} else {
logger.warn("Failed to detect JpaVendorAdapter to use. "
+ "Delegating adapter setup to LocalContainerEntityManagerFactoryBean");
}
} else {
logger.warn("Failed to detect ORM platform to use. "
+ "Delegating JpaVendorAdapter setup to LocalContainerEntityManagerFactoryBean");
}
}