File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Partial model - update. How to update partial object relations? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Partial model - update. How to update partial object relations?" Watch "Partial model - update. How to update partial object relations?" New topic
Author

Partial model - update. How to update partial object relations?

avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
Hey,

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?

wait to here your ideas.

Thank you
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

You might be opening up a big can of worms there!

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's a good project.

Making Associated Hibernate Object Nulls
Gilead stands for Generic Light Entity Adapter


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 !


avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
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.


Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Partial model - update. How to update partial object relations?
 
Similar Threads
JPA(Toplink Essentials) using JTA on Glassfish: Issue In Loading References
mapping One-to-many relationships using NetBeans and Not Hibernate
Answers of Sun's Free Proficiency Assessment
Best mapping approach for reference/LOV/lookup data
are these beans required to be in same ejb-jar?