문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 | ||
springframework:springboot:jpa [2018/07/05 13:56] kwon37xi 만듦 |
springframework:springboot:jpa [2021/08/04 14:42] (현재) kwon37xi [Open Entity Manager In View / Open Session In View (OSIV) 끄기] |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* [[springframework: | * [[springframework: | ||
+ | ===== Open Entity Manager In View / Open Session In View (OSIV) 끄기 ===== | ||
+ | * OSIV는 항상 끄자. | ||
+ | < | ||
+ | spring.jpa.open-in-view: | ||
+ | </ | ||
+ | * '' | ||
+ | |||
+ | <code java> | ||
+ | // SpringBoot 2.1 의 org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.JpaWebConfiguration 참조. | ||
+ | |||
+ | @ConditionalOnProperty(prefix = " | ||
+ | protected static class JpaWebConfiguration { | ||
+ | </ | ||
===== 별도 설정하기 ===== | ===== 별도 설정하기 ===== | ||
줄 7: | 줄 20: | ||
// 최상단에 | // 최상단에 | ||
@EnableConfigurationProperties | @EnableConfigurationProperties | ||
+ | @EnableJpaRepositories(basePackageClasses = MyRepository.class, | ||
+ | entityManagerFactoryRef = " | ||
+ | transactionManagerRef = " | ||
... | ... | ||
줄 33: | 줄 49: | ||
.build(); | .build(); | ||
} | } | ||
+ | </ | ||
+ | |||
+ | <code yml> | ||
+ | my: | ||
+ | jpa: | ||
+ | database-platform: | ||
+ | properties: | ||
+ | hibernate: | ||
+ | dialect: org.hibernate.dialect.MySQL57InnoDBDialect | ||
+ | default_batch_fetch_size: | ||
+ | id.new_generator_mappings: | ||
+ | format_sql: true | ||
+ | show_sql: false | ||
+ | use_sql_comments: | ||
+ | hbm2ddl.auto: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Naming Strategy ===== | ||
+ | * 현재 Spring boot 버전에 [[http:// | ||
+ | * 그 외에 버그가 해결된 버전에서도 기본적으로 Spring 자체의 Naming Strategy를 사용하는데 이게 자동으로 이름을 변환해버리다 보니 의도에 맞지 않게 작동할 수 있음. 차라리 Hibernate 기본을 사용하고 항상 Table, Column 이름을 명시해주는게 편하다. | ||
+ | * [[https:// | ||
+ | * 해결책은 naming strategy를 직접 지정해 줄 것< | ||
+ | // Hibernate 4 | ||
+ | spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy | ||
+ | // or | ||
+ | spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy | ||
+ | |||
+ | // Hibernate 5 | ||
+ | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl | ||
+ | spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl | ||
</ | </ |