단일 컬럼에 유니크 처리

@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

+ Recent posts