cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: How do I get a record for non integer pk?
Date Wed, 16 May 2007 17:08:43 GMT
Exactly. There is an 'objectForPk(.., int)' and another one  
'objectForPk(.., Object)':

   http://cayenne.apache.org/doc20/api/cayenne/org/apache/cayenne/ 
DataObjectUtils.html

Andrus

On May 16, 2007, at 8:01 PM, Bryan Lewis wrote:

> We use that objectForPK() method routinely with a String key and  
> haven't
> had any problems.
> What do you mean by "not working"?  Is it throwing a
> CayenneRuntimeException?
>
>
> Frank wrote:
>> Hello,
>>
>> The code below is not working, as it expects the PK to be integer.
>> There is only one String field in the table defined as a pk.
>>
>> Thanks
>>
>> Frank
>>
>> private void getRecord(String name) {
>>      DataContext context = DataContext.getThreadDataContext();
>>      System s = new System();
>>      s = (System) DataObjectUtils.objectForPK(context,  
>> System.class, name);
>>   form.setDataObject(s);
>>     }
>>
>
>


Mime
View raw message