2016-08-16 24 views
0

このエラーメッセージは、別のエンティティクラスにManytoOne関係を追加するたびに表示されます。このエンティティ階層にIDが定義されていません

クラスは、一貫したアクセスタイプ(フィールドまたはプロパティのいずれか)を使用する必要があります。このエンティティ階層

に定義されたIDは、これは

@Entity 
@Table(name = "CustomerTransaction") 
public class CustomerTransaction implements Serializable {//this is the line with the error message 
    @Id 


    @GeneratedValue(strategy = GenerationType.AUTO) 
    private Long id; 
     @ManyToOne //This generates the problem 
    @JoinColumns({ 
      @JoinColumn(name = "CUS_ID", referencedColumnName = "IDCUSTOMER") }) 


    public Long getId() { 
     return id; 
    } 

    public void setId(Long id) { 
     this.id = id; 
    } 





    private long transactionID; 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date buyDate; 

    public Date getBuyDate() { 
     return buyDate; 
    } 

    public void setBuyDate(Date buyDate) { 
     this.buyDate = buyDate; 
    } 



    public long getTransactionID() { 
     return transactionID; 
    } 

    public void setTransactionID(long transactionID) { 
     this.transactionID = transactionID; 
    } 







    public String getCarYear() { 
     return carYear; 
    } 

    public void setCarYear(String carYear) { 
     this.carYear = carYear; 
    } 

    public Date getTransactionDate() { 
     return transactionDate; 
    } 

    public void setTransactionDate(Date transactionDate) { 
     this.transactionDate = transactionDate; 
    } 
    private String carYear; 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date transactionDate; 

答えて

1

JPAアノテーションは、全てのフィールド上またはアクセサメソッドのいずれかに配置する必要があります私のエンティティの取引ではありません。フィールドprivate Long id@Id@GeneratedValueアノテーションを配置しましたが、ゲッター(public Long getId())では@ManyToOne@JoinColumnsのアノテーションをフィールドに配置しました。後者をフィールド上で動かす。

関連する問題