creating/saving transient objects to database

From: Michael Lepine (mikelepin..mail.com)
Date: Thu Jun 21 2007 - 16:45:52 EDT

  • Next message: Fredrik Liden: "RE: creating/saving transient objects to database"

    I've got a situation where I've got strict POJO objects that I'll need to
    copy data from and into my generated Cayenne classes. My issue is that when
    I copy the data from the bean to the Cayenne class, I don't know whether the
    object exists or not. Thus, I create the Cayenne class instance using
    DataContext.newObject(). Obviously, when I call DataContext.commitChanges(),
    an insert is being attempted on the corresponding table even if a record
    already exists in the database.

    Is there a way to create the Cayenne instance so that the persistent layer
    will know to check whether the record exists and update it instead of always
    attempting an insert?

    Any help and guidance are appreciated.



    This archive was generated by hypermail 2.0.0 : Thu Jun 21 2007 - 16:46:27 EDT