Hello
I have a problem -I jave many to one relation in database and I can't save many side.
I was trying to found out solution,but I didn't find...
After this table Contact is still null
I was trying also
I have a problem -I jave many to one relation in database and I can't save many side.
I was trying to found out solution,but I didn't find...
Code:
//OneToMany
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="owner")
@Column(nullable = false)
private Set<Contact> contacts;
//ManyToOne
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_id", nullable = false )
private User owner;
//Attempt save
user.addContact(contact);
userDAO.save(user);
I was trying also
Code:
contact.setOwner(user);
contactDAO.save(contact);