TransientObjectException - object references an unsaved transient instance - save the transient instance before flushing

前端 未结 2 410
北海茫月
北海茫月 2021-02-12 13:00

I\'ve come across a few good possible answers to my questions, but this is regarding an upgrade from Hibernate 3.4.0GA to Hibernate 4.1.8. So this used to work under the previou

相关标签:
2条回答
  • 2021-02-12 13:03

    NoteItem references a transient (not yet saved) instance of Note which has to be saved before. So specify "Cascade.all" on property note or call saveorupdate on Note first.

    0 讨论(0)
  • 2021-02-12 13:21

    I was facing the same error for all PUT HTTP transactions, after introducing optimistic locking (@Version)

    At the time of updating an entity it is mandatory to send id and version of that entity. If any of the entity fields are related to other entities then for that field also we should provide id and version values, without that the JPA try to persist that related entity first

    Example: we have two entities --> Vehicle(id,Car,version) ; Car(id, version, brand) to update/persist Vehicle entity make sure the Car field in vehicle entity has id and version fields provided

    0 讨论(0)
提交回复
热议问题