Spring JPA에서 Tibero를 사용하기 위한 설정
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>tibero6</groupId>
<artifactId>tibero6-custom</artifactId>
<version>6.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/tibero6-jdbc.jar</systemPath>
</dependency>
</dependencies> package com.example.tiberojpa;
import org.hibernate.dialect.Oracle10gDialect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
public class JPAConfig {
@Autowired
private DataSource dataSource;
public static class TiberoDialect extends Oracle10gDialect { }
@Bean
public EntityManagerFactory entityManagerFactory(){
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(false);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("com.example.tiberojpa");
factory.setDataSource(this.dataSource);
factory.getJpaPropertyMap().put("show-sql", true);
factory.getJpaPropertyMap().put("hibernate.dialect", TiberoDialect.class);
factory.getJpaPropertyMap().put("hibernate.physical_naming_strategy", "org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy");
factory.afterPropertiesSet();
return factory.getObject();
}
@Bean
public PlatformTransactionManager transactionManager(){
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory());
return transactionManager;
}
}
Last updated