Re: Cayenne for SIM-like game

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Dec 20 2004 - 11:44:25 EST

  • Next message: Dave: "Re: Cayenne for SIM-like game"

    > Mike wrote:
    > > You create a local
    > > instance of each using the DataContext.localObjects

    Sax <sanxion200..ahoo.com> wrote:
    > Nice, but what is going on under the hood? Are
    > DataObject instances copied in the
    > DataContext.localObjects() method?
    > I'm worried about any custom fields not part of the
    > values Map.

    Yes, it will create a new data object pointing at the same database record.

    What sort of fields do you have that you're not persisting?
    There's different ways to do it, and it really depends on your needs.

    > Should I keep my server and cayenne objects seperate?

    That's one way. Without any further info, you might create a server object
    that internally delegates to a cayenne object for persisted values. Or you
    might just auto-create cayenne objects from your server objects (pretty much
    just a bean copy operation) and handling database updates that way, but I
    think you lose a lot of the benefit of using cayenne/POJOs by doing this.

    Another possiblity is to create your own localObjects() method that calls
    the cayenne method, then calls your custom code to copy over your
    non-persisted values afterward.

    Or a variation of the above would be to create a server object that the
    cayenne object delegates non-persisted values into.

    > Or should I simply use the extended class generated by
    > cayenne for my custom fields and methods?

    Yes, you should do this in any case.

    At some point, you'll want to add new fields to your database tables (or
    remove old ones or change a type), and if you don't do this, you'll find it
    harder to make these changes. If you use the gap generation pattern
    provided, you can rebuild your parent class at any point without worrying
    about overwriting your code. You can even make it a part of your build
    process so it's always up-to-date.

    -Mike



    This archive was generated by hypermail 2.0.0 : Mon Dec 20 2004 - 11:42:35 EST