본문 바로가기
Programming/Java

springBoot / jpa / hibernate 에서 엔티티의 테이블명, 컬럼명 오류

by Chan_찬 2016. 1. 13.
728x90
spring boot JPA

@Entity
@Table(name="SC_TRAN")
public class Sms extends Message{
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "TR_NUM")
private long id;

위와 같이 어노테이션으로
테이블명도 대문자, 컬럼명도 대문자로 지정되어 있다.
하지만 쿼리가 소문자 or 대소문자 구분이 안되어 나오는 문제..
spring boot 가 자동으로 컬럼명, 테이블명을 넣어서 생기는 문제다.


application.properties에서 naming-strategy를 아래와 같이 수정한다.

spring.datasource.url=jdbc:mysql://localhost/sms?autoReconnect=true&useUnicode=true&characterEncoding=utf8
spring.datasource.username=sms
spring.datasource.password=smspasswd

#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.EJB3NamingStrategy
#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port=8081

#spring.jpa.show-sql=true


application.properties 에 다음 저장

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.EJB3NamingStrategy

출처: http://goo.gl/oF9F24


728x90
728x90
Buy me a coffeeBuy me a coffee

댓글