public class Application{
@Id
private Long id;
@OneToMany(mappedBy = "application")
private List<Licence> licences = new ArrayList<Licence>();
...
}
public class Licence{
@Id
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ID", nullable = false)
private Application application;
...
}
How do I get hibernate to leave licences in application object readonly and not try to persist Licence when I go em.merge(application);
I'm not trying to save Licence with Cascade in Application. Licences have a lot business rules to run before they actually get persisted so I will be calling persist on each licence individually. How do I do this ? This works fine on persist but not on merge.
On merge I keep getting
org.hibernate.TransientObjectException: object is an unsaved transient
instance - save the transient instance before merging: com.cmr.Licence