[TEXO/Hibernate] Help with AnnotationException: No identifier specified [message #691622] |
Fri, 01 July 2011 21:26 |
Mike Cooper Messages: 60 Registered: February 2011 |
Member |
|
|
Hi Folks,
I've got a bit of a problem which is probably due to being a hibernate newbie.
I'm getting these errors when calling getSessionFactory():
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
WARNING: Property vortex.model.Asset.Type not found in class but described in <mapping-file/> (possible typo error)
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
WARNING: Property vortex.model.Asset.AssetTag not found in class but described in <mapping-file/> (possible typo error)
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
WARNING: Property vortex.model.Asset.PurchaseDate not found in class but described in <mapping-file/> (possible typo error)
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
... lots more like above but for different variables and classes ...
... truncated ...
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: vortex.model.Asset
Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity vortex.model.Asset on table Asset
2011-06-30 17:41:59,593 ERROR [vortex.admintool.cli.CliSecurityLoad] loadPerms: Exception getting PermissionManager: org.hibernate.AnnotationException: No identifier specified for entity: vortex.model.Asset
#0: org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:268)
#1: org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:223)
#2: org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
#3: org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
#4: org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
#5: org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
#6: org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
#7: vortex.db.PersistManager.getSessionFactory(PersistManager.java:219)
#8: vortex.db.PersistManager.getSession(PersistManager.java:199)
The vortex.model.Asset class is referenced in hibernate.cfg.xml (see below) and is defined in orm.xml (below). The vortex.model.Asset.AssetTag member is not a class, but a variable in class Asset. Same for the other vortex.model.Asset.* references in the errors.
I've used Texo to generate the orm.xml file which looks like this (truncated version):
<?xml version="1.0" encoding="ASCII"?>
<orm:entity-mappings xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" version="2.0">
<orm:access>FIELD</orm:access>
<orm:entity class="vortex.model.StateInfo" name="StateInfo">
<orm:attributes>
<orm:basic name="IdleTime" optional="true"/>
<orm:basic name="LockTimeout" optional="true"/>
<orm:basic name="RadioSigStrength" optional="true"/>
<orm:basic name="StorageAvail" optional="true"/>
<orm:basic name="BatChargeRemain" optional="true"/>
<orm:basic name="BatCurrentVoltage" optional="true"/>
<orm:basic name="Updated" optional="true">
<orm:temporal>DATE</orm:temporal>
</orm:basic>
<orm:many-to-one name="MobileProvider" optional="true" target-entity="vortex.model.MobileProvider">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
<orm:many-to-one name="PhoneNumber" optional="true" target-entity="vortex.model.PhoneNumber">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
</orm:attributes>
</orm:entity>
<orm:entity class="vortex.model.SystemInfo" name="SystemInfo">
<orm:attributes>
<orm:basic name="osName" optional="true"/>
<orm:basic name="OsVersion" optional="true"/>
<orm:basic name="DevIdent" optional="true"/>
<orm:basic name="Config" optional="true"/>
<orm:basic name="SIM" optional="true"/>
<orm:basic name="IMEI" optional="true"/>
<orm:basic name="IMSI" optional="true"/>
<orm:basic name="DefaultEmailAddr" optional="true"/>
<orm:basic name="Updated" optional="true">
<orm:temporal>DATE</orm:temporal>
</orm:basic>
</orm:attributes>
</orm:entity>
<orm:entity class="vortex.model.Asset" name="Asset">
<orm:attributes>
<orm:basic name="ID" optional="true"/>
<orm:basic name="Type" optional="true"/>
<orm:basic name="status" optional="true"/>
<orm:basic name="AssetTag" optional="true"/>
<orm:basic name="PurchaseDate" optional="true">
<orm:temporal>DATE</orm:temporal>
</orm:basic>
<orm:basic name="OwnerNameFromUser" optional="true"/>
<orm:basic name="OwnerInfoFromUser" optional="true"/>
<orm:basic name="Notes" optional="true"/>
<orm:basic name="Created" optional="true">
<orm:temporal>DATE</orm:temporal>
</orm:basic>
<orm:basic name="Updated" optional="true">
<orm:temporal>DATE</orm:temporal>
</orm:basic>
<orm:many-to-one name="SystemInfo" optional="true" target-entity="vortex.model.SystemInfo">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
<orm:many-to-one name="Hardware" optional="true" target-entity="vortex.model.Hardware">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
<orm:many-to-one name="Registration" optional="true" target-entity="vortex.model.Registration">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
<orm:many-to-one name="Agent" optional="true" target-entity="vortex.model.Agent">
<orm:join-column/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-one>
<orm:many-to-many name="StateInfo" target-entity="vortex.model.StateInfo">
<orm:order-column/>
<orm:join-table name="Asset_StateInfo"/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-many>
<orm:many-to-many name="Entities" target-entity="vortex.model.Entity">
<orm:order-column/>
<orm:join-table name="Asset_Entities"/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-many>
<orm:many-to-many name="Apps" target-entity="vortex.model.App">
<orm:order-column/>
<orm:join-table name="Asset_Apps"/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-many>
<orm:many-to-many name="Locations" target-entity="vortex.model.Location">
<orm:order-column/>
<orm:join-table name="Asset_Locations"/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-many>
<orm:many-to-many name="Policies" target-entity="vortex.model.Policy">
<orm:order-column/>
<orm:join-table name="Asset_Policies"/>
<orm:cascade>
<orm:cascade-persist/>
<orm:cascade-merge/>
<orm:cascade-refresh/>
</orm:cascade>
</orm:many-to-many>
</orm:attributes>
</orm:entity>
...truncated...
My hibernate.cfg.xml contains
<mapping class="vortex.model.Asset"/>
<mapping class="vortex.model.StateInfo"/>
<mapping resource="vortex/resources/orm.xml"/>
I have only listed a few of the classes in hibernate.cfg.xml so far. I will add the rest once I get this working.
Would greatly appreciate any pointers on this one!
Thanks.
mike
|
|
|
Re: [TEXO/Hibernate] Help with AnnotationException: No identifier specified [message #691630 is a reply to message #691622] |
Fri, 01 July 2011 21:35 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Mike,
In your domain model you probably did not model an id and version eAttribute. Hibernate/ORM's in general need at least
one id property/member and often also a version eattribute/property. I often choose the following strategy to solve this:
- create a java class (called Identifier or something) with an id and version member and annotate them using JPA annotations
- annotate this java class with @MappedSuperclass (read about mapped super class in the jpa docs)
In ecore you can also choose a different approach (which I like slightly better than the above):
- create an interface EClass (called Identifiable for example) and give it 2 eattributes: db_id and db_version.
- let all other eclasses inherit from this EClass (it is an interface so in the generated java code it will be added to
the implements of the java class)
- then add an orm annotation file with the correct annotations to tell the orm generation what the id/version members are.
See the attached files for an example of this. I also added an example persistence.xml and orm.xml.
gr. Martin
On 07/01/2011 11:26 PM, Mike Cooper wrote:
> Hi Folks,
>
> I've got a bit of a problem which is probably due to being a hibernate newbie.
>
> I'm getting these errors when calling getSessionFactory():
>
>
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
> WARNING: Property vortex.model.Asset.Type not found in class but described in <mapping-file/> (possible typo error)
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
> WARNING: Property vortex.model.Asset.AssetTag not found in class but described in <mapping-file/> (possible typo error)
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
> WARNING: Property vortex.model.Asset.PurchaseDate not found in class but described in <mapping-file/> (possible typo error)
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader checkForOrphanProperties
> ... lots more like above but for different variables and classes ...
> ... truncated ...
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class: vortex.model.Asset
> Jun 30, 2011 5:41:59 PM org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity vortex.model.Asset on table Asset
> 2011-06-30 17:41:59,593 ERROR [vortex.admintool.cli.CliSecurityLoad] loadPerms: Exception getting PermissionManager:
> org.hibernate.AnnotationException: No identifier specified for entity: vortex.model.Asset
> #0: org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:268)
> #1: org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:223)
> #2: org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
> #3: org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
> #4: org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
> #5: org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
> #6: org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
> #7: vortex.db.PersistManager.getSessionFactory(PersistManager.java:219)
> #8: vortex.db.PersistManager.getSession(PersistManager.java:199)
>
>
> The vortex.model.Asset class is referenced in hibernate.cfg.xml (see below) and is defined in orm.xml (below). The
> vortex.model.Asset.AssetTag member is not a class, but a variable in class Asset. Same for the other
> vortex.model.Asset.* references in the errors.
>
> I've used Texo to generate the orm.xml file which looks like this (truncated version):
>
> <?xml version="1.0" encoding="ASCII"?>
> <orm:entity-mappings xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" version="2.0">
> <orm:access>FIELD</orm:access>
> <orm:entity class="vortex.model.StateInfo" name="StateInfo">
> <orm:attributes>
> <orm:basic name="IdleTime" optional="true"/>
> <orm:basic name="LockTimeout" optional="true"/>
> <orm:basic name="RadioSigStrength" optional="true"/>
> <orm:basic name="StorageAvail" optional="true"/>
> <orm:basic name="BatChargeRemain" optional="true"/>
> <orm:basic name="BatCurrentVoltage" optional="true"/>
> <orm:basic name="Updated" optional="true">
> <orm:temporal>DATE</orm:temporal>
> </orm:basic>
> <orm:many-to-one name="MobileProvider" optional="true" target-entity="vortex.model.MobileProvider">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> <orm:many-to-one name="PhoneNumber" optional="true" target-entity="vortex.model.PhoneNumber">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> </orm:attributes>
> </orm:entity>
> <orm:entity class="vortex.model.SystemInfo" name="SystemInfo">
> <orm:attributes>
> <orm:basic name="osName" optional="true"/>
> <orm:basic name="OsVersion" optional="true"/>
> <orm:basic name="DevIdent" optional="true"/>
> <orm:basic name="Config" optional="true"/>
> <orm:basic name="SIM" optional="true"/>
> <orm:basic name="IMEI" optional="true"/>
> <orm:basic name="IMSI" optional="true"/>
> <orm:basic name="DefaultEmailAddr" optional="true"/>
> <orm:basic name="Updated" optional="true">
> <orm:temporal>DATE</orm:temporal>
> </orm:basic>
> </orm:attributes>
> </orm:entity>
> <orm:entity class="vortex.model.Asset" name="Asset">
> <orm:attributes>
> <orm:basic name="ID" optional="true"/>
> <orm:basic name="Type" optional="true"/>
> <orm:basic name="status" optional="true"/>
> <orm:basic name="AssetTag" optional="true"/>
> <orm:basic name="PurchaseDate" optional="true">
> <orm:temporal>DATE</orm:temporal>
> </orm:basic>
> <orm:basic name="OwnerNameFromUser" optional="true"/>
> <orm:basic name="OwnerInfoFromUser" optional="true"/>
> <orm:basic name="Notes" optional="true"/>
> <orm:basic name="Created" optional="true">
> <orm:temporal>DATE</orm:temporal>
> </orm:basic>
> <orm:basic name="Updated" optional="true">
> <orm:temporal>DATE</orm:temporal>
> </orm:basic>
> <orm:many-to-one name="SystemInfo" optional="true" target-entity="vortex.model.SystemInfo">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> <orm:many-to-one name="Hardware" optional="true" target-entity="vortex.model.Hardware">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> <orm:many-to-one name="Registration" optional="true" target-entity="vortex.model.Registration">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> <orm:many-to-one name="Agent" optional="true" target-entity="vortex.model.Agent">
> <orm:join-column/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-one>
> <orm:many-to-many name="StateInfo" target-entity="vortex.model.StateInfo">
> <orm:order-column/>
> <orm:join-table name="Asset_StateInfo"/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-many>
> <orm:many-to-many name="Entities" target-entity="vortex.model.Entity">
> <orm:order-column/>
> <orm:join-table name="Asset_Entities"/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-many>
> <orm:many-to-many name="Apps" target-entity="vortex.model.App">
> <orm:order-column/>
> <orm:join-table name="Asset_Apps"/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-many>
> <orm:many-to-many name="Locations" target-entity="vortex.model.Location">
> <orm:order-column/>
> <orm:join-table name="Asset_Locations"/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-many>
> <orm:many-to-many name="Policies" target-entity="vortex.model.Policy">
> <orm:order-column/>
> <orm:join-table name="Asset_Policies"/>
> <orm:cascade>
> <orm:cascade-persist/>
> <orm:cascade-merge/>
> <orm:cascade-refresh/>
> </orm:cascade>
> </orm:many-to-many>
> </orm:attributes>
> </orm:entity>
> ...truncated...
>
>
> My hibernate.cfg.xml contains
>
>
> <mapping class="vortex.model.Asset"/>
> <mapping class="vortex.model.StateInfo"/>
>
> <mapping resource="vortex/resources/orm.xml"/>
>
> I have only listed a few of the classes in hibernate.cfg.xml so far. I will add the rest once I get this working.
>
> Would greatly appreciate any pointers on this one!
>
> Thanks.
> mike
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [TEXO/Hibernate] Help with AnnotationException: No identifier specified [message #691639 is a reply to message #691633] |
Fri, 01 July 2011 22:39 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Mike,
Here is an example, the identifiable.ecore should be one directory up and then in a subdirectory base, so the structure
should be something like this:
base
identifiable.ecore
model
library.ecore
Yes you can say that Texo should use the ID property of the eattribute but this is more used for XML serialization than
for anything else, and as Texo has this annotations model concept I first wanted to make use of this as it allows more
finetuned configuration (like the id generation).
gr. Martin
On 07/02/2011 12:09 AM, Mike Cooper wrote:
> Hi Martin,
>
> Many thanks! I was actually just starting to look at this and your
> http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details posting.
>
> Can you give an example of a .ecore file which has an example EClass which refers to Identifiable? I'm not quite sure
> how that works. Generally I use the Eclipse Model Editor on a .ecorediag file which auto syncs to the .ecore file. (I'll
> bet you never use the Editor. :) ). So if you can give some example of what the .ecore file looks like with an example
> EClass I can try to reproduce that with the Editor.
>
> Also, my .ecore does set iD="true" (as set from Model Editor) for those members which are the ID fields:
>
>
> <eClassifiers xsi:type="ecore:EClass" name="Asset">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="ID" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"
> iD="true">
> ....
> <eClassifiers xsi:type="ecore:EClass" name="Registration">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="ID" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELongObject"
> iD="true"/>
>
>
>
> Shouldn't texo configure the orm.xml to setup the Id in such cases? Perhaps Model Editor is just using "iD=true" and
> this is not a standard part of ecore?
>
> mike
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.03612 seconds