0

i'm trying to create tabel entity with composite primary key. so i tried to create @Embeddable class with all the primary keys and use @EmbeddedId on the field that represents the primary keys. but i get this error:

Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

i wos tried to follow this link bat noting work what i'm doing wrong?

here is my code

DocEntity

@Entity(name = "doc")
@Table(name = "doc")
public class DocEntity extends baseDataBase implements Serializable
{
    private static final long serialVersionUID = 1L;


    @EmbeddedId
    private DocID docID;

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "DocID")
    @JsonProperty
    @NotEmpty
    private short id;

    @Column(name = "DocDescription")
    @JsonProperty
    @NotEmpty
    private String docDescription;

    @Column(name = "DocPath")
    @JsonProperty
    @NotEmpty
    private String docPath;

     // getters, setters ,equals, hashCode
}

DocID

@Embeddable
public class DocID implements Serializable
{
    private static final long serialVersionUID = 1L;

    @Column(name = "DocName")
    @JsonProperty
    @NotEmpty
    protected  String docName;


    @Column(name = "DocVersion")
    @JsonProperty
    @NotEmpty
    protected  String docVersion;

 // getters, setters ,equals, hashCode
}

what i'm doing wrong?

Community
  • 1
  • 1
yogev levi
  • 369
  • 1
  • 4
  • 21
  • 1
    If you mean *two* primary keys, then you are missing the meaning of "primary". There is only one per table. You should clarify if you mean *composite primary key* or *two* different primary keys. – Gordon Linoff Nov 06 '16 at 15:30
  • Sorry I thought it was clear that it refers for a composite primary key i will edit the post – yogev levi Nov 06 '16 at 15:35

0 Answers0