Hi, I have a OneToMany relationship between entities Contact and Email. When I create a Contact and add to him 1 or more Email I need to set the FK column in Email table to the right Contact of that email...
I tried this:
Code:
@Entity
class Contact{
@Id
......
@OneToMany(mappedBy="contact", cascade=CascadeType.ALL)
private Set<ContactEmail> email;
}
@Entity
class Email{
@Id
......
@ManyToOne
@JoinColumn(name="CONTACT_ID")
private Contact contact;
}
When in my test package I call:
em.persist(contact); //(where contact has 2 emails associated)
it creates 1 contact, 2 emails records but the FK column "CONTACT_ID" is empty...
how can I set its value with rhe right Contact ID of that email?
thanks in advance!