작성
·
573
0
아래와 같이 두 군데 모두 설정을 해 봤는데요
format_sql 설정은 안먹네요 ㅜㅜ ;;;
[ 로그 예시 ]
DEBUG org.hibernate.SQL - select lnequest0_.id as id1_0_, lnequest0_.created_at as created_2_0_, lnequest0_.updated_at as updated_3_0_, lnequest0_.deleted_at as deleted_4_0_, lnequest0_.description as descript5_0_, lnequest0_.end_at as end_at6_0_, lnequest0_.reward_amount as reward_a7_0_, lnequest0_.reward_currency as reward_c8_0_, lnequest0_.reward_remain as reward_r9_0_, lnequest0_.reward_total as reward_10_0_, lnequest0_.start_at as start_a11_0_, lnequest0_.thumbnail_url as thumbna12_0_, lnequest0_.title as title13_0_, lnequest0_.type as type14_0_, lnequest0_.user_constraints as user_co15_0_ from korbit.lne_quests lnequest0_ inner join korbit.lne_quizzes quizzlist1_ on lnequest0_.id=quizzlist1_.quest_id limit ?
[yml 설정]
spring:
profiles: jpa
jpa:
database-platform: org.hibernate.dialect.MySQL57Dialect
database: mysql
hibernate:
ddl-auto: validate
naming:
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
properties:
hibernate:
# show_sql: true
format_sql: true
use_sql_comments: true
dialect: org.hibernate.dialect.MySQL57Dialect
# ddl-auto: validate
use-new-id-generator-mappings: false
[ 멀티 database 인스탄스를 위한 DataSource 및 TransactionManager 설정 ]
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(entityManagerFactoryRef = "jpaKorbitApiEntityManagerFactory",
transactionManagerRef = "jpaKorbitApiTransactionManager",
basePackages = ["xxx.jpa.korbitapi.repository"])
class JpaKorbitApiConfig {
@Autowired(required = false)
private val persistenceUnitManager: PersistenceUnitManager? = null
@Bean(name = ["jpaKorbitApiDataSource"])
@ConfigurationProperties(prefix = "spring.datasource.korbitapi")
fun jpaKorbitApiDataSource(): DataSource {
val dataSource = DataSourceBuilder.create().type(HikariDataSource::class.java).build()
//dataSource.connectionInitSql = "SET NAMES utf8mb4; set @@session.time_zone = '+00:00'"
return dataSource
}
@Bean(name = ["jpaKorbitApiEntityManagerFactoryBuilder"])
fun jpaKorbitApiEntityManagerFactoryBuilder(): EntityManagerFactoryBuilder {
val adapter = HibernateJpaVendorAdapter()
adapter.setShowSql(true)
adapter.setPrepareConnection(true)
adapter.setDatabase(Database.MYSQL)
adapter.setDatabasePlatform("org.hibernate.dialect.MySQL57Dialect")
adapter.setGenerateDdl(false)
val properties = HashMap<String, String?>()
properties["hibernate.ddl-auto"] = "validate"
properties["show_sql"] = "false"
properties["format_sql"] = "true"
properties["use_sql_comments"] = "true"
properties["hibernate.naming.implicit-strategy}"] = org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
properties["hibernate.naming.physical-strategy}"] = org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
properties["hibernate.use-new-id-generator-mappings"] = "false"
return EntityManagerFactoryBuilder(
adapter, properties, persistenceUnitManager)
}
:::
}