Amadeu Cabanilles
Amadeu Cabanilles

Reputation: 973

JAVA: This class has a composite primary key. It must use an ID class

I have this error in my eclipse editor This class has a composite primary key. It must use an ID class. , but the class does not has a composite primary key, because the id is a Long

   @SuppressWarnings("serial")
    @Entity
    @Table(name = "T_PRODUCT")
    @SequenceGenerator(name = "seqPRODUCT", sequenceName = "SEQ_PRODUCT")
    public class Product extends ItemBase implements java.io.Serializable {

        @Id
        private Long id;


@Id
    @Column(name = "ID", unique = true, nullable = false, precision = 38, scale = 0)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqPRODUCT")
    public Long getId() {
        return this.id;
    }

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

Upvotes: 1

Views: 3068

Answers (1)

pandaadb
pandaadb

Reputation: 6466

Hibernate is seeing both annotations on the property and on the getter-method and therefore assumes that you are using a composite key.

Upvotes: 3

Related Questions