4 Replies Latest reply on Mar 3, 2009 11:14 AM by Adam Warski

    Issue on return type be an Interface !

    Amar Singh Newbie

      I came across this problem while using Hibernate-envers-3.4-SNAPSHOT with Hibernate-3.3.GA or Hibernate-3.4-SNAPSHOT. Below is my hbm.xml file:

      <?xml version="1.0"?>
      <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
      <hibernate-mapping default-lazy="false" package="com.xyz.fwk.persistence.hibernate.impl.bug.demo.test">
       <class name="Trade" table="trade" batch-size="64" lazy="false">
       <id name="id" type="int" access="field">
       <generator class="native"></generator>
       <component name="tradeId" class="TypeIdentifier">
       <property name="id" column="TRADE_ID"/>
       <property name="type" column="TRADE_ID_TYPE"/>

      My class definition for Trade is:

      @Audited (this doesn't matter)
      public class Trade implements Serializable {
       protected int id;
       protected ITypeIdentifier tradeId ;
       public Trade() { }
       public ITypeIdentifier getTradeId() { return tradeId; }
       public void setTradeId(ITypeIdentifier i) { tradeId =i ; }

      Since the getTradeId returns and ITypeIdentifier which is an interface, (hence has no super class) the method addPropertiesFromClass(XClass clazz) in org.hibernate.envers.configuration.metadata.reader.AuditedPropertiesReader

      when trying to analyze ITypeIdentifier fails because the interface has no super class !

       private void addPropertiesFromClass(XClass clazz) {
       XClass superclazz = clazz.getSuperclass();
      (super class will be null for an interface return type )
       if (!"java.lang.Object".equals(superclazz.getName())) {
       addFromProperties(clazz.getDeclaredProperties("field"), "field", fieldAccessedPersistentProperties);
       addFromProperties(clazz.getDeclaredProperties("property"), "property", propertyAccessedPersistentProperties);