3 Replies Latest reply on Feb 23, 2011 5:15 AM by Benoit Heinrich

    @OrderColumn and @AuditMappedBy, MappingException: points to a property that doesn't exist

    Benoit Heinrich Newbie

      Hi guys,


      I'm working on a project where we're using envers and since we're migrating from jboss 4.2.3 to jboss 6.0.0.Final (finally ), I'm then upgrading the old envers to the new one.

      Part of the migration I've changed all the @IndexColumn by the new JPA2 @OrderColumn and it seems that envers doesn't work with that new annotation (or I might do something wrong here )


      Also, since we're now using the @OrderColumn the "position" column on the referenced entity has been removed as the hibernate documentation (and JPA2 specs) ask for it.  Since it's been removed I'm getting the problem.


      Here is the example mapping:




      public class OrganizationEntity {


                @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)

                @JoinColumn(name = "org_entity_id", columnDefinition = "int", nullable = false)

                @OrderColumn(name = "position", columnDefinition = "tinyint", nullable = false)

                @AuditMappedBy(mappedBy = "organizationEntity", positionMappedBy = "position")

        private List<OrganizationEntityContactDetail> contactDetailList;





      public class OrganizationEntityContactDetail {

        @ManyToOne(fetch = FetchType.EAGER)

                @JoinColumn(name = "org_entity_id", columnDefinition = "int", nullable = false, insertable = false, updatable = false)

                private OrganizationEntity organizationEntity;



      Every time I deploy this I'm getting the following error:

      Caused by: org.hibernate.HibernateException: could not init listeners

                at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205) [:3.6.0.Final]

                at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1980) [:3.6.0.Final]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842) [:3.6.0.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902) [:3.6.0.Final]

                ... 73 more

      Caused by: org.hibernate.MappingException: @AuditMappedBy points to a property that doesn't exist: com.example.services.organization.entity.OrganizationEntityAddress.position

                at org.hibernate.envers.configuration.ClassesAuditingData.forcePropertyInsertable(ClassesAuditingData.java:83)

                at org.hibernate.envers.configuration.ClassesAuditingData.updateCalculatedFields(ClassesAuditingData.java:72)

                at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:86)

                at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:97)

                at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:129)

                at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:335)

                at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198) [:3.6.0.Final]

                at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181) [:3.6.0.Final]

                at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194) [:3.6.0.Final]

                ... 76 more

      I'm doing something wrong here but I'm not sure what.


      Do I need to put back the JPA mapping for the "position" column on the referenced entity?

      Do I need to use the positionMappedBy with new @OrderColumn annotation?


      If I remove the positionMappedBy then it seems to deploy better, but then the position isn't set in the auditing table.



      Thanks for helping.