Re: Cayenne & Flex

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jun 16 2006 - 02:04:36 EDT

  • Next message: Lothar Krenzien: "Re: IllegalStateException in DataRowStore (thrown by LRUMap)"

    > ((Integer) DataObjectUtils.pkForObject(this)).intValue();

    An equivalent shorter form will be this:

         DataObjectUtils.intPkForObject(this));

    > ObjectId objectId = new ObjectId("Contact", CONTACT_ID_PK_COLUMN,
    > id);
    > setObjectId(objectId);

    Theoretically this should work as Cayenne checks for manual id
    changes on commit and does the right thing. The catch is that the old
    id is used as a key to look up the registered object in DataContext,
    so there may be undesired side effects. A cleaner way may look like
    this:

       this.objectId.getReplacementIdMap().put(CONTACT_ID_PK_COLUMN, new
    Integer(id));

    Andrus

    On Jun 16, 2006, at 5:14 AM, Malcolm Edgar wrote:

    > Hi All,
    >
    > I am looking at using Cayenne with Flex. Flex provides a Data
    > Services layer
    > which transforms Java object into matching JavaScript classes. As
    > Flex
    > needs to get and set the object id values, I want to know if what I
    > am doing
    > below is the correct pattern?
    >
    > regards Malcolm Edgar
    >
    >
    > package samples.contact;
    > ..
    >
    > public class Contact extends _Contact
    > {
    > public int getContactId() {
    > return ((Integer) DataObjectUtils.pkForObject(this)).intValue
    > ();
    > }
    >
    > public void setContactId(int id) {
    > ObjectId objectId = new ObjectId("Contact",
    > CONTACT_ID_PK_COLUMN,
    > id);
    > setObjectId(objectId);
    > }
    >
    > }



    This archive was generated by hypermail 2.0.0 : Fri Jun 16 2006 - 02:05:02 EDT