We have tried a number of approaches to get the AnnotationsConfiguration to read our (single) annotated class, and have that referenced from existing .hbm-mapped classes, with no success.
We are able to use the AnnotationsConfiguration to load .hbm mapped classes, but when we convert one class to Annotations, it ignores it.
We have tried using <mapping class="xxx.yyy.Zzz"> as well as programmatically invoking addAnnotatedClass() and have had no success.
We have copied the configuration syntax from the examples directory (one example mixes hbm with annotations) and had no success.
Please advise if you have a solution or recommendation, thanks.
Note also that the console log reports many .hbm files being read, but says nothing about the annotated class being processed.
Hibernate version:
core: 3.1.2 annotations: Beta8
Mapping documents:
Code:
import org.hibernate.annotations.Entity;
/**
* @pojo.interface name="Place"
*/
@Entity
@Table(name="place")
public class Place extends Persistent { ...
relevant snippet from hibernate.cfg.xml Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping resource="com/fgm/imsma/pojo/impl/Accdevice.hbm.xml"/>
. . .
<mapping class="com.fgm.imsma.pojo.impl.Place"/>
</session-factory>
Code to set up SessionFactory using Annotations:Code:
private static SessionFactory getSessionFactory() {
if (sessionFactory == null) {
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.configure();
sessionFactory = cfg.buildSessionFactory();
}
return sessionFactory;
}
Full stack trace of any exception that occurs:Code:
[exec] 08:51:20,650 ERROR [ImsmaEnumHelper] java.lang.RuntimeException: SessionFactory error: Association references unmapped
class: com.fgm.imsma.pojo.impl.Place
[exec] java.lang.RuntimeException: SessionFactory error: Association references unmapped class: com.fgm.imsma.pojo.impl.Place
[exec] at com.fgm.imsma.biz.HibernateSession.getSessionFactory(HibernateSession.java:33)
[exec] at com.fgm.imsma.biz.HibernateSession.currentSession(HibernateSession.java:62)
[exec] at com.fgm.imsma.biz.HibernateHelper.findQuery(HibernateHelper.java:482)
---------------
full hibernate.cfg.xml
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping resource="com/fgm/imsma/pojo/impl/Accdevice.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Accdeviceversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Accident.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Accidentversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/AllowedValue.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Attachment.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Cdfvalue.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Customdefinedfield.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Fieldreport.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Fieldreportdesc.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Fieldreportgraphic.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteer.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteeralternativename.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteerlevel.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Geopoint.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Geospatialinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazard.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazardversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazdevice.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazdeviceversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreduc.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducdevice.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducdeviceversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducmarking.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducmarkingversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducmethod.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducmethodversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Hazreducversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/ImsmaEnum.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Injury.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Injuryversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Location.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Locationinfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Map.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Markinginfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Markinginfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Module.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Mre.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Mredetail.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Mredetailversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Mreinfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Ordnance.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Orgaccreditationinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Organisation.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Permission.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Qa.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Qainfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Qamethodinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Qamethodinfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Receivedmre.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Receivedmreversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/ReportTemplate.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Revisionlog.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Role.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Securitylevel.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Securityleveltype.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Suitableforinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Suitableforinfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Translation.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/User.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Vegetationinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Vegetationinfoversion.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Victim.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Victiminfoversion.hbm.xml"/>
<!-- mapping package="com.fgm.imsma.pojo.impl"/-->
<mapping class="com.fgm.imsma.pojo.impl.Place"/>
</session-factory>
<!--
<mapping resource="com/fgm/imsma/pojo/impl/Place.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteer.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteerlevel.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Gazetteeralternativename.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Geospatialinfo.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Geopoint.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/Map.hbm.xml"/>
<mapping resource="com/fgm/imsma/pojo/impl/ImsmaEnum.hbm.xml"/>
-->
</hibernate-configuration>