Which one would you recommend:
- Hibernate integration with a OpenSessionInViewFilter?
- Or a GWT remote service which actually creates DTO's - meaning model
objects for a certain widget - out of multiple Hibernate instrumented
domain objects?
I prefer the second one because:
- there is a cleaner separation between the different layers
- no hibernate dependency on the view layer, which makes it easier to
switch to jdbc or something else. Because with option one you gotta
deal with the LazyInitException
- less traffic, you only send to the client exactly what he needs, in
the correct format
- ...
I would like to hear your thoughts...
There are a couple of solutions. You could have a separate DTO
hierarchy. Or, you could have code that just creates copies of your
domain objects themselves, terminating lazy collections with nulls
instead -- basically an "object marshaling layer" that makes a
subsetted copy of your object graph. (This is good if you have no
control over your serialization layer; we're doing this with Axis 1.4
in another project now.)
Or, you can hook into GWT's RPC. See this thread -- http://
groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/
thread/669e3d31b60bb1be -- for an example of that.
Cheers!
Rob