How can i write a JPA Entity without a primary Key ?
My DB table is combined from two columns (user_id, company_id)
both are foreign keys with manyToOne relation.
Code:
@Entity
@Table(name="COMPANY_CONTACTS")
public class CompanyContacts {
@EmbeddedId
private CompanyContactsPK companyContactsPK;
}
@Embeddable
public class CompanyContactsPK implements Serializable{
private static final long serialVersionUID = -1294432203426788661L;
@ManyToOne
@JoinColumn(name = "COMPANY_ID", referencedColumnName = "CMP_COMPANY_ID")
private Company company;
@ManyToOne
@JoinColumn(name = "USER_ID", referencedColumnName = "USR_PERSON_ID")
private User user;
}
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: hibernateModel.CompanyContacts.company in hibernateModel.Company.companyContacts