-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: AnnotationsConfiguration and Annotations ignoring classes
PostPosted: Wed Feb 15, 2006 10:13 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
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>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 10:59 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
We seem to have solved this problem. By tracing the source we see that the AnnotationsConfiguration class expects to find javax.persistence.Entity as an annotation. We were using org.hibernate.annotations.Entity instead.

I'm dissapointed that Hibernate Annotations fails silently in this case, with no indication that the expected annotation is not on a class that is defined to be annotated. Generally I'm finding that config errors and other exceptions in JBoss products are lacking, and I recommend that JBoss focus on this.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 11:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
whenever we are being notified about such issues we normally implement them.

you can notify us about this by opening up a jira issue for it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 1:12 pm 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
done! Note that it is also important to document these issues here for people following threads and searching for solutions in the forums, hence my note.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 11:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
put it in the annotations FAQ

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.