cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Anderson" <>
Subject RE: Using Cayenne in GWT wthout DTOs
Date Mon, 22 Sep 2008 18:24:38 GMT
> I just thought maybe there could have been something similar to
> hibernate4gwt in the hibernate land. Maybe I could work on something.

I certainly don't want to crush any aspirations to enhance the
development experience, but I want to make sure that you're not trying
to reach an unreachable goal. It sounds to me like your goal is to get
out of having beans. That won't be possible, but you most certainly can
generate the beans - in fact, if you were to do so, I'd probably use it
myself for future projects.

The bottom line is that GWT-RPC won't serialize anything unless it looks
like a bean. The tricky thing here is that POJOs look like beans; to be
precise, they store row data in fields that GWT-RPC can serialize.
CayenneDataObjects don't do this, and therefore can not be directly
serialized; they need a bean to act as a packet definition. For complete
details, see -- but don't be
fooled, while a CDO may be serializable (if a subclass implements
IsSerializable), GWT-RPC still won't transmit row data; it will simply
allow you to define the message to be a CDO, but will still expect an
object which implements IsSerializable, and will only serialize the
fields defined in the lowest level implementation, not in its super

This behavior is intentional! It is not a flaw in design, or a bug, or
an oversight, so don't expect it to change in the future.

You could take the XML mapping file as input for a code generator and
use that information to generate beans, the two service interfaces, a
factory to instantiate and initialize the beans from CDOs, and a merger
to dump the beans received from the client back in to the CDOs. You
might even be able to generate that code via the Modeler with some
templates if you're clever.

Theoretically, you could store the fields of the beans in the CDO
implementations, emulating that characteristic of POJOs, but I certainly
wouldn't recommend doing that. It wouldn't solve the problem that data
needs to be copied back and forth, and it would give the CDOs multiple
responsibilities, which is a general programming taboo.


View raw message