Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';不创建约束_Java_Hibernate_Jpa - Fatal编程技术网

Java Can';不创建约束

Java Can';不创建约束,java,hibernate,jpa,Java,Hibernate,Jpa,我无法使用uniqueConstraints{@UniqueConstraint(columnNames=“name”)} 一级产品: @Entity @Table(appliesTo="produit") public class Produit implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = Generatio

我无法使用
uniqueConstraints{@UniqueConstraint(columnNames=“name”)}

一级产品:

  @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>();
错误:

注释类型表的属性uniqueConstraints未定义


您应该使用
uniqueConstraints={@UniqueConstraint(columnNames=“name”)}
,因为它是@Table注释的元素,您也可以引用它

我认为您有以下导入:

import org.hibernate.annotations.Table;
但要添加
uniqueConstraints
,您需要将其替换为JPA等效项:

import javax.persistence.Table;
import javax.persistence.Table;