You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Mary-Anne Wolf <mg...@mocasystems.com> on 2008/03/06 17:55:40 UTC

Why no getPropertyNames?

In the DataObject, there is readProperty and writeProperty, but there
does not appear to be a method to get the names of the available properties.

I could hack around this limitation by creating a custom superclass for
my CayenneDataObject instances,
but WHY is there no getPropertyNames method?  Is there a way to get the
names of the properties
which I have not figured out?

Mary-Anne


Re: Why no getPropertyNames?

Posted by Robert Zeigler <ro...@puregumption.com>.
All of the meta-data is stored in the obj entity (and the dbentity).
So, something like:
obj.getObjEntity().getAttributes(); //return attribute (non- 
relationship properties)
obj.getObjEntity().getRelationships();//return relationships (1-1, 1- 
many, etc.)

You can get the property names from there. You can also get the  
corresponding DbAttribute to determine table and column names, joins,  
etc.

Robert

On Mar 6, 2008, at 3/610:55 AM , Mary-Anne Wolf wrote:

> In the DataObject, there is readProperty and writeProperty, but there
> does not appear to be a method to get the names of the available  
> properties.
>
> I could hack around this limitation by creating a custom superclass  
> for
> my CayenneDataObject instances,
> but WHY is there no getPropertyNames method?  Is there a way to get  
> the
> names of the properties
> which I have not figured out?
>
> Mary-Anne
>


Re: Why no getPropertyNames?

Posted by Mike Kienenberger <mk...@gmail.com>.
Model metadata is available through the ObjEntity, ObjAttribute,
ObjRelationship, DbEntity, DbAttribute, and DbRelationship classes.

Typically, you would use an EntityResolver to get the appropriate
object you wish to work with.   For 3.0, you can use
[Data/Object]Context.getEntityResolver() to acquire one.   You can
also fetch one via DataNode as well.


On 3/6/08, Mary-Anne Wolf <mg...@mocasystems.com> wrote:
> In the DataObject, there is readProperty and writeProperty, but there
>  does not appear to be a method to get the names of the available properties.
>
>  I could hack around this limitation by creating a custom superclass for
>  my CayenneDataObject instances,
>  but WHY is there no getPropertyNames method?  Is there a way to get the
>  names of the properties
>  which I have not figured out?
>
>
>  Mary-Anne
>
>