Hibernate saveorupdate is not updating
- Easy to implement when you have "hello world" sample with 3 or 4 entities living quite independently from each other.But it's a pity to maintain when you have dozens of entities all of them being part or collection of the other...In the first case the entity is saved, in the latter case it is updated.
This week we touch upon a subject that may seem trivial at first: how to save an entity..To speed up the development we successfully use Hyper JAXB 3 ( which generates 90% of the code, though still need to handcraft some JPA annotations anyway. I see that Jeanne Boyarsky has already answered your question over at Code Ranch.😉 But I'll answer your question for other readers of this blog: the difference is that a new entity is one that has just been created in Java but has not been persisted in the database yet, while a detached entity exists in Java I have a problem I'd like to tell you about : it's about jpa, entity, modification, undo (cancel modification)...From section 15.3 of the JDO 2.2 specification: ===== If two relationships (one on each side of an association) are mapped to the same column, the field on only one side of the association needs to be explicitly mapped.
The field on the other side of the relationship can be mapped by using the mapped-by attribute identifying the field on the side that defines the mapping.
I guess it depends on how the optimistic locking is implemented, but then I still can't think of the examples.