我无法在班级网站中使用uniqueConstraints{@UniqueConstraint(columnNames="name")})
1级产品:
@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;
错误:
对于注释类型表
,未定义属性uniqueConstraints
答案 0 :(得分:0)
你应该使用uniqueConstraints = {@UniqueConstraint(columnNames="name")})
,因为它是@Table注释的元素,你也可以参考uniqueConstraints
答案 1 :(得分:0)
我认为你有这个导入:
import org.hibernate.annotations.Table;
但要添加uniqueConstraints
,您需要将其替换为等效的JPA:
import javax.persistence.Table;