-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @CollectionOfElements trouble
PostPosted: Thu Oct 22, 2009 8:32 am 
Newbie

Joined: Thu Oct 22, 2009 8:13 am
Posts: 1
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???


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.