You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Jean-François Smigielski <jf...@gmail.com> on 2007/08/05 11:43:16 UTC

questions about reflection

Hello, list!

I use cayenne in a brand new project, a text-based online RPG. I refactor
from scratch an old RPG written in PHP/MySQL. I discovered cayenne a few
days ago. After spending some time to test it, it will be my final choice
(thanks a lot for your work, cayenne is *really* easy to use). That's it for
the context of my question :)

I try to write a JSP that proposes a low-level administration of the
persistent objects. I would be able to:

   1. discover the class of the persistent objects
   2. discover their properties
   3. allow setting and getting these properties

I am not yet able to discover the classes, I still have to feed them by
hand. It would be easy if I had access to the XML map, but I didn't find yet
the right utility class.
To discover the properties, I used the name convention of the modeler,
naming the properties with the suffix "_PROPERTY". And to get and set these
properties, I retrieve the value of the fields ending with "_PROPERTY" and I
call readProperty/writeProperty with this value.

I am sure there exists better ways to achieve this. Better and more robust.
Please, can you tell me useful hints, or helpful URL, or even code samples
that could help me?

Thank you.

JFS.

Re: questions about reflection

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi there,

Runtime access to the mapping metadata is done via EntityResolver [1]:

DataContext context = ...
EntityResolver resolver = context.getEntityResolver();

EntityResiolver contains information about ObjEntities (java  
classes), DbEntities (DB tables) and the mapping between them.

Hope this helps.
Abdrus


[1] http://cayenne.apache.org/doc20/api/cayenne/org/apache/cayenne/ 
map/EntityResolver.html



On Aug 5, 2007, at 12:43 PM, Jean-François Smigielski wrote:

> Hello, list!
>
> I use cayenne in a brand new project, a text-based online RPG. I  
> refactor
> from scratch an old RPG written in PHP/MySQL. I discovered cayenne  
> a few
> days ago. After spending some time to test it, it will be my final  
> choice
> (thanks a lot for your work, cayenne is *really* easy to use).  
> That's it for
> the context of my question :)
>
> I try to write a JSP that proposes a low-level administration of the
> persistent objects. I would be able to:
>
>    1. discover the class of the persistent objects
>    2. discover their properties
>    3. allow setting and getting these properties
>
> I am not yet able to discover the classes, I still have to feed  
> them by
> hand. It would be easy if I had access to the XML map, but I didn't  
> find yet
> the right utility class.
> To discover the properties, I used the name convention of the modeler,
> naming the properties with the suffix "_PROPERTY". And to get and  
> set these
> properties, I retrieve the value of the fields ending with  
> "_PROPERTY" and I
> call readProperty/writeProperty with this value.
>
> I am sure there exists better ways to achieve this. Better and more  
> robust.
> Please, can you tell me useful hints, or helpful URL, or even code  
> samples
> that could help me?
>
> Thank you.
>
> JFS.