I'm looking for input into a design approach. I have a requirement to serialize an entity, send it to a remote client that does not have a JPA client, get it back and then update the database.
I have the first three portions working fine. My questions is the approach for saving the entity after it is returned from the client.
My current approach is:
- Retreive it again from the database so it is managed
- Check the version to prevent concurrent modifications
- Copy the fields from the serialized entity to the managed one
- Save the managed entity using merge()
I would appreciate your input on several aspects
- Is there a better overall approach to saving the modified entity?
-
When copying the fields a simple field assignment is not recognized as a modification but a setter is a change
2a.
this.name = modified.getName()
results in no update statement sent to the database2b.
this.setName(modified.getName())
results in an update - Collections of children are throwing
ClassCastException
. How can I successfully update (add/remove/change) a collection?
This is with openjpa 2.4.1 if it is relevant to the discussion.
Thanks for your input!
Tim
Aucun commentaire:
Enregistrer un commentaire