The model is a collection of entities with relations between them.
Entity 1 has reference to other entities which have reference to other entities and ...
for example A->B->c->(1:m)D
In some case entity in the model is a graph of objects that has more than 10 relations level.
When you update an entity , you dont expect that the use will give you the complete relations.
now, say that the user send you A for update and b attribute (ref to B) is null- so in this case you will nulify the relation:
solution1: the user must supply ref to B with atleast the B id (maybee he change the ID).
there are few more solution that i have . I will be happy to hear yours.
My question is how to deal with list reference. suppose A has List.
The client cannot send listB as null, but we dont expect for load list only in order to represent the ID references like we did in 1:1.
In hibernate when you load A without his references it set proxy on the references ,this help to know (and load) if this reference changed by the client and need to be update or the client didnt touch it at all and want to update only entity A.
it can be an ugly solution to required from the client to set some proxies or any other alternative on the uncahnged reference?
I did some Hibernate and GWT work, and didn't want the proxies on the client side. We used Gilead, which strips out the proxies and replaces them with nulls. You can send the unattached entity back to the server and merge it back into the database relatively unscathed. There are concurrency issues that the HibernateSession saves you from, so use at your own risk.
It permits you to send Persistent entities (and especially the partially loaded ones) outside the JVM (GWT, Flex, Web-Services, Google AppEngine ...) without pain.
No LazyInitialisationException. No DTO mapping. Just POJO and Domain Driven Design !
Joined: Jan 10, 2007
Thanks a lot for your answer.
I implement my own proxy cleaner (in less than 50 rows).
My ptoxy cleaner in case of onetoone proxy initiate this reference and set only the id (in one to one reference you can get the id from proxy without the need to init it), so when the client send me object i see if its only "light entity" and in case it light i dont cascade it.
The problem is with collections proxy. i dont want to send them as null, so i think i will create my own collection and in case of proxy collection i will mark it with my own collection.
subject: Partial model - update. How to update partial object relations?