我不能uniqueConstraints{@UniqueConstraint(columnNames="name")})
無法創建約束
1級Produit類網站添加約束nomsociete:
@Entity
@Table(appliesTo="produit")
public class Produit implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long refProduit;
@Column(name="nomsociete")
private String nomsociete;
@OneToMany(fetch = FetchType.LAZY,mappedBy="produit")
private List<Site> listSites=new ArrayList<Site>();
2級的網站:
@Entity
@Table(appliesTo="site",uniqueConstraints
{@UniqueConstraint(columnNames="name")})
public class Site implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long refsite;
@Column(name="nomsociete")
private String nomsociete;
@JoinColumn(name = "refProduit")
@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private Produit produit;
錯誤:
The attribute uniqueConstraints is undefined for the annotation type Table
感謝您的回覆@ holmis83 –