[appengine-java] Re: DTO object

2010-11-08 Thread Starman
Remap these complex types onto native Java types while copying your
entities onto your dtos... or are you sending your entities to the
client directly?

Usually, you will not want to send the entities to the client as it
exposes your data model directly. You should create your service layer
so as to be friendly to other clients besides your own. Create a
remoting API that is a bit more abstract than your entities so as to
be easily exposed through a REST API for instance.

When I copy my entities onto my dtos, some entity fields don't even
make it into the dto. Others only have getters in the dto because they
are read-only to the client. Those that do get into the dto get
converted to native Java types. For instance, Text gets converted to
String. Key gets encoded to a url friendly string. If I have Set
fields on the entities to manager my relations (property lists), I
remap those to ArrayList... First, don't serialize interfaces to GWT
client, you'll get Javascript bloat. Then, Hashmap is costly to
serialize because String.hashCode() is not the same on in Java and in
Javascript. Hence, all the items need to be re-inserted into a client
side map. Of course, in Web mode, performance is good enough... but in
development mode, your data transfers will become really slow for
somewhat big transfers.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: DTO object

2010-11-08 Thread Koen Maes
Hi Starman, Thx for your reply.

>From what I understand, you are "manually" copying the properties from
the Entity to the DTO. But this process is automated in GWT 2.1

So, I am not sending my entities directly, but the proxies as per the
documentation : 
http://code.google.com/webtoolkit/doc/latest/DevGuideRequestFactory.html

"An entity proxy is a client-side representation of an entity,
otherwise known as a DTO (Data Transfer Object). With RequestFactory,
entity proxies are interfaces that extend the EntityProxy interface,
which is the hook used to indicate that an object can be managed by
RequestFactory. RequestFactory automatically populates bean-style
properties between entities on the server and the corresponding
EntityProxy on the client, which simplifies using the DTO pattern.
Furthermore, the EntityProxy interface enables RequestFactory to
compute and send only changes ("deltas") to the server."

"Entity proxies simply extend the EntityProxy interface and use the
@ProxyFor annotation to reference the server-side entity being
represented. It is not necessary to represent every property and
method from the server-side entity in the EntityProxy, only getters
and setters for properties that should be exposed to the client."

The entity proxies are merely interfaces that are being populated by
the new GWT 2.1 RequestFactory framework. I have no control over this
copying process. Per definition, getters/setters of the real entity
are injected into the EntityProxy whenever they are present;

So my problem still stands : what about complex values like
com.google.appengine.api.datastore.Email that are not known by the
client side code ? How to transfer these complex values to the client.

Any insight very welcome !

Koen

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.