RE: Using Cayenne in GWT wthout DTOs

From: Scott Anderson (sanderso..irvana.com)
Date: Wed Sep 17 2008 - 14:04:18 EDT

  • Next message: Steave: "errors with derby and hsqldb (i need to switch from mysql to an embedded db)"

    This topic has been discussed in this group before, but I'll reiterate
    the general concepts. You can't serialize persistent objects, period.
    There are many reasons why, but I don't have time to list them all, so
    here are the three that are most important in my mind.

    Reason #1:
    In order for the GWT compiler to transform your CayenneDataObjects in to
    JavaScript, it would have to resolve a graph that would encapsulate the
    entire Cayenne library. I could list the reasons why you can't do that,
    but I don't have time to write an essay right now, so save yourself the
    headache by taking me at my word when I say it won't work.

    Reason #2:
    The purpose of the server-side code is to enable validation and
    authentication. You can expose un-verified, un-authenticated database
    access to the client-side code without RPC. If you're not going to
    validate or authenticate, don't bother introducing the proxy. Cayenne
    will work just as well in a stand-alone application -- the Modeler is a
    good example of that.

    Reason #3:
    By writing the code to copy information out of beans and in to the
    CayenneDataObjects, you will be forcing yourself to plug any validation
    holes you would otherwise surely forget. Additionally, by using beans
    targeted to the needs of your operations, the amount of data that is
    required to go back and forth through the RPC tunnel will be
    substantially lower.

    If you were to serialize the CayenneDataObjects, which is impossible,
    then for *every* operation you'd have to send the entire graph of the
    object in question -- which is probably the entire database if you
    reverse-map your relationships.

    Hope this helps,
    Scott

    -----Original Message-----
    From: Chanda Fake [mailto:chand..usakatimes.com]
    Sent: Wednesday, September 17, 2008 1:07 AM
    To: use..ayenne.apache.org
    Subject: Using Cayenne in GWT wthout DTOs

    Hi

    I have seen from the mailing list that some people have used Cayenne
    with
    GWT successfully.What is the best way to expose Cayenne model to GWT
    without
    using DTOs which I consider as duplication of work. Am trying to use my
    Cayenne domain objects in GWT and running into some usual issues GWT.
    Am
    thinking if there is a way to create a module with the offending class
    "CayenneDataObject" and then including it using <inherits ..>. What have
    others done.

    Thanks in advance



    This archive was generated by hypermail 2.0.0 : Wed Sep 17 2008 - 14:08:01 EDT