Suggested Pages

Tuesday, May 26, 2015

JPA multiple Unique Constraint

BeanExample



@Entity
@Table(name = "BEAN_TABLE", uniqueConstraints = @UniqueConstraint(columnNames = { "FIRST_COLUMN", "SECOND_COLUMN" }))
public class BeanExample {

 
 private static final long serialVersionUID = 1L;

 @Id
 @Column(name = "ID")
 private String id = UUID.randomUUID().toString();

 
 @Column(name="FIRST_COLUMN")
 private String firstColumn;


 @Column(name="SECOND_COLUMN")
 private String secondColumn;

 ....
}

No comments :

Post a Comment

Suggested Pages