There is no ID defined for this entity hierarchy
<p>I am stuck with this error message, that appears every time I want to add a ManytoOne relationship with another entity class.</p>

<blockquote>
  <p>The class must use a consistent access type (either field or property). There is no ID defined for this entity hierarchy</p>
</blockquote>

<p>This is my entity Transaction</p>

<pre><code>@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;
</code></pre>