JPA (Java Persistence API)
-
@Table, @UniqueConstraintJPA (Java Persistence API) 2021. 11. 15. 21:26
jpa 에서 두 개 이상의 칼럼을 unique 걸 때 사용 파일 @Builder @AllArgsConstructor @NoArgsConstructor @Data @Entity @Table( uniqueConstraints = { @UniqueConstraint( name="likes_uk", columnNames = {"imageId", "userId"} ) } ) public class Likes { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @JoinColumn(name = "imageId") @ManyToOne private Image image; @JoinColumn(name = "userId") @ManyToO..