Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-dev] Get an Entity fields

Hi Milen,

There have definitely been significant changes, hopefully for the better. We have split the model up into context model and resource model. The resource model more directly reflects the resource (java, xml). In the xml this is a generated EMF model that uses the WTP translator framework to read/write the xml. In the java it represents the annotations on the Types and Attributes. The context model pulls together the persistence.xml, orm.xml and java resource models and uses common API. It gives context to the java annotations, so that a JavaResourcePersistentType in the resource model with Entity, Table, SecondaryTable annotations on it becomes a PersistentType with an Entity TypeMapping in the context model. The context model interfaces are used by the UI. Given that information are you looking for the resource model fields, or the context model fields? I will show the api to traverse the context model.

JpaProject.getRootContext() : JpaRootContextNode
JpaRootContextNode.getPersistenceXml(): PersistenceXml
PersistenceXml.getPersistence() : Persistence
Persistence.persistenceUnits() : ListIterator<PersistenceUnit> (will contain 0 or 1 PersistenceUnits, we don't support multiple yet) PersistenceUnit.classRefs() : ListIterator<ClassRef> (mappingFileRefs() if you want the orm.xml entities)
ClassRef.getJavaPersistentType() : JavaPersistentType
JavaPersistentType.attributes() : ListIterator<JavaPersistentAttribute>

That gives you access to all the JavaPersistentAttributes in your Java entities. If you want the resource model you can call JavaPersistentAttribute.getResourcePersistentAttribute(). If you need more help than that, you could show me the code your were using before, then I could determine whether you can achieve this solely with the context model interfaces, or if you really need the resource model. I hope this helps clear things up some.


Manov, Milen wrote:

I've noticed that JPA API is changed significantly and I need some help to get a list of an Entity fields. I have created a JpaFile instance and get its JavaRsourceModel but from that point I am in a loss. Please help.
Kind Regards,


wtp-dev mailing list

Back to the top