org.springframework.dao.InvalidDataAccessApiUsageException:
org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.test.entity.Parent.Child_RefId -> com.test.entity.Child;
nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.test.entity.Parent.Child_RefId -> com.test.entity.Child
1 Replies
You should include cascade="all" (if using xml) or cascade=CascadeType.ALL (if using annotations) on your collection mapping.
This happens because you have a collection in your entity, and that collection has one or more items that are not present in the database. By specifying the above options you tell hibernate to save them to the database when saving their parent.