remote client lazy loading or DTO?
zihong Jul 5, 2005 3:43 PMI have been searching for answers on how to load object domain models to remote clients in the ejb3 paradigm, in both jboss and hibernate forums. I found many discussions, for example,
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=62275
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=63277
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=62990
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=37388
http://forum.hibernate.org/viewtopic.php?t=930457&highlight=remote+client+proxy
http://article.gmane.org/gmane.comp.java.hibernate.devel/1433/
It seems lots of people have the same question/confusion as me, however, so far I have not found any satisfactory answer to the question.
Here are my related questions which I try to ask in a different perspective:
1. Should we keep the *whole* data model graph in the object domain model (POJOs)?
If the anser is yes, remote client loading will be problematic, no matter if it is lazy or eager loading. For lazy loading, currently, jboss and EJB3 spec doesn't support lazy loading from remote, you will have to implement a client proxy on your own. For eager loading, well, you don't really want to send remote clients the whole data graph, right?
If the answer is no for *whole* graph, but just keep small graph, ie, object domain model keeps only limited relationships within a small section of the graph, leave majority of relationships not linked. This way, the eager fetching is not too bad, since your object graph is very limited. Then, what is the logical way of breaking up those relationships in the object model? A good example will be very helpful. On the other hand, then, you will need code logic to keep these not linked relationships, kind of hacking to me.
2. The other extreme is not to keep relationships at all, not even in the server entity beans, hence, no relationship problems to solve. Well, the relationships are now in your bean methods, weaved with all the table IDs. In this case, what is the point of using CMP, besides another way of writing SQL statements?
3. In EJB2 and earlier, the DTO (or value objects) is the only way to go. What new value does ejb3 bring us, as far as the remote clients are concerned?
I guess a remote client lazy loading mechanim is not going to solve the whole issue, because then, the remote clients will have to manage the relationships, make sure they are in sync with the server. Comments?
-Zihong