I have Employee class:
Code:
public class Employee implements Serializable{
@Id@GeneratedValue
@Column(name="OBJECTID")
private Long objectId;
@Column (name="FIRST_NAME")
private String firstName;
@Column(name="LAST_NAME")
private String lastName;
@ManyToOne (cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn (name="LOCATION")
private Location location;
@CollectionOfElements(targetElement=Contact.class)
@JoinTable(name="hiber_test_contact", joinColumns={@JoinColumn (name="EMPLOYEE_ID")})
@IndexColumn(name="SORT")
private List<Contact> contacts;
And also Contact class:
Code:
public class Contact implements Serializable{
@Id@GeneratedValue(strategy=GenerationType.AUTO)
private Long objectId;
@Column(name="EMPLOYEEID")
private Long employeeId;
@Column(name="SORT",unique=true)
private Integer sort;
@Column(name="CONTCT")
private String contact;
@Column(name="COMMENT")
private String comment;
when I tried to save Employee I get
Quote:
org.hibernate.MappingException: Foreign key (FKC1BB56242AA52251:hiber_test_contact [contacts_objectId])) must have same number of columns as the referenced primary key (hiber_test_contact [EMPLOYEE_ID,SORT])
what's wrong???