I'm trying to save 2 entities in AppFuse (Struts2, Hibernate and Spring) at once, Here is an example (Address and person are new objects):
person.setAddress(address);
personManager.save(person);
But this doesn't work, i get this exception:
object references an unsaved transient instance - save the transient
instance before merge
I have to do:
addressManager.save(address);
person.setAddress(address);
personManager.save(person);
In person model i have declared Address like that:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "person", cascade= CascadeType.ALL)
public Address getAddress() {
return this.address
}
Are there any way to save this new entities at once?
Thanks in advance..!