spring.jpa.open-in-view is enabled by default.
Therefore, database queries may be performed during view rendering.
Explicitly configure spring.jpa.open-in-view to disable this warning

 

JPA 세팅 후에 작업하다보니 다음과 같은 경고성 로그를 마주하게 되었다.

 

없애는 방법은 JPA의 open-in-view 를 명시해주면 된다.

application.properties

 

true 값이 디폴트이며

 

open-in-view 에 대한 이야기 도 있다

 

본인의 경우 false 세팅후에 save 한 시퀀스 값을 가져오지 못하는 이슈가 발생해

true 로 명시하여 경고를 없앴다

'Database > JPA' 카테고리의 다른 글

[JPA] Data too long for column 문자열 길이 이슈  (0) 2024.06.17
JPA 인덱스(INDEX)  (0) 2024.06.05
JPA 유니크(UNIQUE)  (0) 2024.06.05
JPA 연동 에러  (0) 2024.05.27

데이터 등록시 JPA의 문자열 길이는 디폴트가 varchar(255) 이기 때문에

255자를 초월하는 경우 다음과 같이 에러가 발생한다

 

@Column(length = 500)
private String testData;

 

다음과 같이 길이를 조정하면 해결할 수 있다

 

그외에 varchar 가 아닌 타입을 쓰고 싶을 수 있는데 그러한 경우

@Column(length = 500)
@Lob
private String testData;

 

다음과 같이 적용시켜주면 된다.

만약 컬럼 length를 지정해주지 않으면 lob을 적용시켜도 같은 에러가 발생한다.

 

만약 컬럼 길이를 정해주지 않으면

빌드할때 생성되는 JPA 테이블을 보면

tinyText 가 생성되는 것을 알 수 있는데

 

명확한 길이를 정해주면

text로 변경된다

'Database > JPA' 카테고리의 다른 글

[JPA] open-in-view 경고  (0) 2024.12.06
JPA 인덱스(INDEX)  (0) 2024.06.05
JPA 유니크(UNIQUE)  (0) 2024.06.05
JPA 연동 에러  (0) 2024.05.27

 

단일 인덱스 설정

@Table(
        indexes = {
                @Index(name = "idx_tb_group_group_code", columnList = "group_code"),
                @Index(name = "idx_tb_group_group_name", columnList = "group_name")
        }
)

인덱스 확인

 

동작 확인

 

 

다중 인덱스 설정

@Table(
        indexes = {
                @Index(name = "idx_tb_group_group", columnList = "group_name, group_desc")
        }
)



@Column(name = "group_name", nullable = false)
private String groupName;

@Column(name = "group_desc")
private String groupDescription;

 

 

 

'Database > JPA' 카테고리의 다른 글

[JPA] open-in-view 경고  (0) 2024.12.06
[JPA] Data too long for column 문자열 길이 이슈  (0) 2024.06.17
JPA 유니크(UNIQUE)  (0) 2024.06.05
JPA 연동 에러  (0) 2024.05.27

 

 

단일 컬럼에 유니크 처리

@Column(name = "group_code", nullable = false, unique = true)
private String groupCode;

 

 

 

 

다중 컬럼에 유니크 처리

@Table(
        uniqueConstraints = {
                @UniqueConstraint(
                        name = "Unique_test",
                        columnNames = {"group_code", "group_name"}
                )
        }
)


@Column(name = "group_code", nullable = false)
private String groupCode;

@Column(name = "group_name", nullable = false)
private String groupName;

 

 

유니크 여부 조회

 

유티크 테스트

 

 

 

 

 

'Database > JPA' 카테고리의 다른 글

[JPA] open-in-view 경고  (0) 2024.12.06
[JPA] Data too long for column 문자열 길이 이슈  (0) 2024.06.17
JPA 인덱스(INDEX)  (0) 2024.06.05
JPA 연동 에러  (0) 2024.05.27

please set 'jakarta.persistence.jdbc.url' for common cases or 'hibernate.dialect' when a custom Dialect implementation must be provided

 

 

application.yml

jpa:
  properties:
    hibernate:
      dialect: org.hibernate.dialect.MySQLDialect

 

 세팅 후 다른 에러로 바뀌었다 ㅎㅎ

'Database > JPA' 카테고리의 다른 글

[JPA] open-in-view 경고  (0) 2024.12.06
[JPA] Data too long for column 문자열 길이 이슈  (0) 2024.06.17
JPA 인덱스(INDEX)  (0) 2024.06.05
JPA 유니크(UNIQUE)  (0) 2024.06.05

+ Recent posts