[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [dali-dev] FW: Get all entities from the project
|
Hi Karen,
I am interested in this as well using the latest Dali 1.0 WTP
milestone. Say after the entities have been generated, I have some
tooling that later wants to update an entity (say to set an optimistic
concurrency version field).
How would I do this in the latest Dali code (until an API is
established)? I don't see the PersistenceProject that you mentioned.
I think ideally it would be nice to call an API to get all
PersistenceUnits for the project, and then get all Entities from each
PersistenceUnit. Then it would be nice if I could easily modify an
Entity model representation and have it update the actual Java file.
For example, I get an EnityObject from the Dali APIs and then I can do
EntityObject.setVersion( "versionFieldName") or something like that and
it would add the appropriate @version annotation to the specified
field. I realize that's probably asking a lot (I did open a feature
request to capture this), so for now I think it's probably okay if I can
just get a list of the Entities somehow; then I can just use the JDT
api's to modify the base Java file (which is ugly, but should work).
Thanks
Tom
Karen Moore wrote:
Hi Dimiter,
We don't currently have api for this in 0.5 and I would recommend
opening an enhancement request against 1.0 to include this as api. In
0.5 your best bet is to call PersistenceProject.persistenceFiles().
This will return you an iterator of PersistenceFile objects. Then
PersistenceFile.getPersistentTypes will return the Collection of
PersistentTypes. Each PersistentType has a TypeMapping on it which can
be Entity, MappedSuperclass, Embeddable. You can use
PersistnentType.getTypeMappingKey() and compare it to
Entity.Key.INSTANCE to check if it is an Entity.
This has changed some in 1.0 and we need to have api for it (even if it
is provisional or internal for now). I hope this helps you.
Karen