When saving an entity having the following property:
@ManyToMany
private Set<Landmark> landmarks;
the following exception might occur:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ctb.trust.core.restaurant.domain.Landmark
Set `cascade` as follows:
@ManyToMany(cascade = CascadeType.ALL)
private Set<Landmark> landmarks;
ONLY IF its behavior is appropriate for you.
Otherwise, you can save them manually.
Reference:
http://stackoverflow.com/questions/2302802/object-references-an-unsaved-transient-instance-save-the-transient-instance-be
No comments:
Post a Comment