tags:

views:

22

answers:

2

I'm using Apache Cayenne as an ORM in my web application and I want to get a list of all entity classes that are managed by Cayenne (for example [Person.class,Account.class,...]).

My goal is to register these classes in an Object<->PrimaryKey Converter for easy parameter handling.

How would I do that?

Thanks.

EDIT: I'm using Cayenne 3.0

+1  A: 

Take a look at the examples and the Javadocs - every aspect of Cayenne is accessible from the API. E.g. you could:

  1. Get a reference the your Datamap by e.g. following the path: DataContext -> EntityResolver -> DataMap
  2. Iterate on all DBEntities or better on all ObjEntities (if they're already mapped - but you can map at runtime dynamically too) - see the methods of DataMap for doing all these operations, such as: DataMap#getObjEntities() or DataMap#getDbEntities() and the others.
  3. For all those properties, there are not only getters but also setters if you want to change something at runtime is not a problem.
A. Ionescu
A: 

The Cayenne class has methods for mapping an object to a primary key objectforPK . That might do what you're after.

RodeoClown