cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Cayenne & Flex
Date Fri, 16 Jun 2006 06:04:36 GMT


> ((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);
>    }
>
> }


Mime
View raw message