object references an unsaved transient instance

org. hibernate .TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:
 
This is mainly encountered in the cascade operation of ManyToOne, such as a new object is new, and it is saved into a new new object (that is, not persistent) before it is saved.
The solution is to check out the object before saving or updating (this is a persistent state).
The solution is to set the cascade of many-to-one to:  cascade="save-update,persist"

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327029637&siteId=291194637