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
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.
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