You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Tore Halset <ha...@pvv.ntnu.no> on 2007/10/26 14:11:31 UTC

Persistent+ObjAttribute -> value

Hello.

I am not so used to the Persistent interface. How can I get the value  
for a given ObjAttribute in a Persistent object? If the Persistent is  
a DataObject I could use readProperty.

Regards,
  - Tore.

Re: Persistent+ObjAttribute -> value

Posted by Tore Halset <ha...@pvv.ntnu.no>.
On Oct 26, 2007, at 14:29 , Andrus Adamchik wrote:

> On Oct 26, 2007, at 3:11 PM, Tore Halset wrote:
>
>> I am not so used to the Persistent interface. How can I get the  
>> value for a given ObjAttribute in a Persistent object? If the  
>> Persistent is a DataObject I could use readProperty.
>
> Yes, there's no common superclass accessors. Instead Cayenne  
> internally uses ClassDescriptor to access properties. Users can do  
> too:
>
> ClassDescriptor d = context.getEntityResolver().getClassDescriptor 
> ("MyEntity");
> Property p = d.getProperty("myProperty");
> Object value = p.readProperty(myObject);
>
> Also ClassDescriptor has visitor methods to traverse all class  
> properties.

Ok. Thanks.

  - Tore.



Re: Persistent+ObjAttribute -> value

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Oct 26, 2007, at 3:11 PM, Tore Halset wrote:

> Hello.
>
> I am not so used to the Persistent interface. How can I get the  
> value for a given ObjAttribute in a Persistent object? If the  
> Persistent is a DataObject I could use readProperty.
>
> Regards,
>  - Tore.

Yes, there's no common superclass accessors. Instead Cayenne  
internally uses ClassDescriptor to access properties. Users can do too:

ClassDescriptor d = context.getEntityResolver().getClassDescriptor 
("MyEntity");
Property p = d.getProperty("myProperty");
Object value = p.readProperty(myObject);

Also ClassDescriptor has visitor methods to traverse all class  
properties.

Andrus