shaun <wojing..astmail.com.au> wrote:
> On Wed, 2005-04-27 at 09:52 -0400, Mike Kienenberger wrote:
> > shaun <wojing..astmail.com.au> wrote:
> > > Hi cayenne users,
> > >
> > > Is it possible to get all relationship and attribute names from a
> > > DataObject or would I need to get this info from the DataMap?
> > > In EOF i would use the following methods: toOneRelationshipKeys,
> > > toManyRelationshipKeys, attributeKeys on an EO.
> >
> > It's best to get this information from the DataMap. However, you can
easily
> > add convenience methods to your DataObject class generation template to
make
> > it more transparent.
> >
> > For example, here's some code I use to get attributes (inside a
DataObject
> > class):
> >
> > EntityResolver entityResolver =
> > getDataContext().getEntityResolver();
> > ObjEntity objEntity =
entityResolver.lookupObjEntity(getClass());
> > Collection attributes = objEntity.getAttributes();
>
>
> I thought I would need to do something like that. I looked at the API
> for ObjEntity and it has all the goodies I need. Thanks for your reply
> and code example, much appreciated.
Another alternative to setting in the code generation template is to create
a super-superclass for all of your DataObjects. You can set this superclass
in the modeler.
Use "BaseDataObject" and it will be placed like this: CayenneDataObject <-->
BaseDataObject <--> _MyClass <--> MyClass
Then all of your custom DataObjects will inherit the convenience methods.
This archive was generated by hypermail 2.0.0 : Wed Apr 27 2005 - 21:56:36 EDT