I work on a client-server application that works like that :
1- the client calls the server to get a object from the DB
2- the server opens a hibernate session and get() an entity. Then closes the session.
3- in order to reduce the data transfered through the network, only a part of the data is copied into a Data Transfer Object.
4- the client updates the data, and send the Data Transfer Object back to the server.
5- the server converts the DTO to a new entity.
6- so the question is:
How to persist/merge the data from the client with the data from the database without overiding non-null values stored in the DB ?
Do I need to use update() ? merge() ? do I need to use the “dynamic-update=true” property ?
I think the only safe strategy is to load current entity form DB in step 5 and then to copy DTO into it before saving it again.