5 Replies Latest reply on Feb 5, 2007 2:50 AM by Tom Baeyens

    hibernate AnnotationConfiguration rather than Configuration

    Chris Russell Newbie

      I am trying to persist an annotated @Entity object but I do not have a mapping resource foo.hbm.xml.
      If HibernateHelper.java returned an AnnotationConfiguration rather than
      a Configuration It would seem I could then specify a property in hibernate.cfg.xml such as

      <mapping package="foo"/>
      <mapping class="foo.MyAnnotatedFooClass"/>

      Which then would allow my annotated class to be stored using a HibernateLongInstance
      rather than as a blob (since my annotated class is Serializable)
      So Then I put this at the top of jbpm.varmapping.xml (which I havent seen as example but seems to work...except for the resulting exception).
       <bean class="org.jbpm.context.exe.matcher.ClassNameMatcher">
       <field name="className"><string value="foo.MyAnnotatedFooClass" /></field>
       <variable-instance class="org.jbpm.context.exe.variableinstance.HibernateLongInstance" />

      From hibernate docs

      Interesting here is the use of AnnotationConfiguration. The packages and annotated classes are declared in your regular XML configuration file (usually hibernate.cfg.xml).
      Note that you can mix the hbm.xml use and the new annotation one.
      The resource element can be either an hbm file or an EJB3 XML deployment descriptor. The distinction is transparent for your configuration process.

      Exception received when I try this strategy
      javax.ejb.EJBException: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping package="foo.MyAnnotatedFooClass"/>