|
|
|
@ -34,6 +34,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager;
|
|
|
|
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.EntityManagerFactory;
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
import java.sql.Date;
|
|
|
|
|
import java.sql.Time;
|
|
|
|
@ -56,6 +57,8 @@ import java.util.Map;
|
|
|
|
|
sqlSessionFactoryRef = "sqlSessionFactory"
|
|
|
|
|
)
|
|
|
|
|
public class DataSourceConfig {
|
|
|
|
|
@Value("${spring.jpa.properties.hibernate.hbm2ddl.auto}")
|
|
|
|
|
String hbm2ddlAuto;
|
|
|
|
|
// JPA
|
|
|
|
|
//static final String[] REPO_PACKAGES = new String[]{"com.xit.biz.**.repository", "com.xit.core.**.repository"};
|
|
|
|
|
static final String[] ENTITY_PACKAGES = new String[]{"com.xit.biz.**.entity", "com.xit.core.**.entity"};
|
|
|
|
@ -88,14 +91,14 @@ public class DataSourceConfig {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Value("${spring.jpa.properties.hibernate.hbm2ddl.auto}") String hbm2ddlAuto) {
|
|
|
|
|
public EntityManagerFactory entityManagerFactory() {
|
|
|
|
|
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
|
|
|
|
vendorAdapter.setDatabasePlatform(jpaProperties().getDatabasePlatform());
|
|
|
|
|
vendorAdapter.setDatabase(jpaProperties().getDatabase());
|
|
|
|
|
vendorAdapter.setShowSql(jpaProperties().isShowSql());
|
|
|
|
|
|
|
|
|
|
HibernateProperties hibernateProperties = new HibernateProperties();
|
|
|
|
|
hibernateProperties.setDdlAuto(hbm2ddlAuto);
|
|
|
|
|
hibernateProperties.setDdlAuto(this.hbm2ddlAuto);
|
|
|
|
|
Map<String, Object> propMap = hibernateProperties.determineHibernateProperties(
|
|
|
|
|
jpaProperties().getProperties()
|
|
|
|
|
, new HibernateSettings());
|
|
|
|
@ -106,15 +109,17 @@ public class DataSourceConfig {
|
|
|
|
|
emf.setPersistenceUnitName("default");
|
|
|
|
|
emf.setJpaVendorAdapter(vendorAdapter);
|
|
|
|
|
emf.setJpaPropertyMap(propMap); //jpaProperties().getProperties());
|
|
|
|
|
emf.afterPropertiesSet();
|
|
|
|
|
//emf.getJpaPropertyMap().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(entityManagerFactory))
|
|
|
|
|
return emf;
|
|
|
|
|
|
|
|
|
|
return emf.getObject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Primary
|
|
|
|
|
@Bean
|
|
|
|
|
public PlatformTransactionManager jpaTransactionManager(LocalContainerEntityManagerFactoryBean entityManagerFactory) {
|
|
|
|
|
public PlatformTransactionManager jpaTransactionManager() {
|
|
|
|
|
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
|
|
|
|
transactionManager.setEntityManagerFactory(entityManagerFactory.getObject());
|
|
|
|
|
transactionManager.setEntityManagerFactory(entityManagerFactory());
|
|
|
|
|
transactionManager.setNestedTransactionAllowed(true);
|
|
|
|
|
return transactionManager;
|
|
|
|
|
}
|
|
|
|
@ -166,7 +171,7 @@ public class DataSourceConfig {
|
|
|
|
|
conf.setMapUnderscoreToCamelCase(true);
|
|
|
|
|
conf.setLocalCacheScope(LocalCacheScope.SESSION); // SESSION / STATEMENT
|
|
|
|
|
conf.setJdbcTypeForNull(JdbcType.OTHER); // NULL / VARCHAR / OTHER 파라메터에 null 값이 있는경우 처리
|
|
|
|
|
conf.setLazyLoadTriggerMethods(new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString")));
|
|
|
|
|
conf.setLazyLoadTriggerMethods(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
|
|
|
|
|
conf.setCallSettersOnNulls(true); // 조회시 null값 필드 set
|
|
|
|
|
conf.setAggressiveLazyLoading(true);
|
|
|
|
|
conf.setReturnInstanceForEmptyRow(true);
|
|
|
|
|