2 Replies Latest reply on Jun 9, 2008 7:28 AM by Adam Warski

    Inconsistent field mappings used in joined columns

    talios Newbie

      'lo,

      I noticed some inconsistency with field column names used by envers for joined tables, I've entered this currently in JIRA as http://jira.jboss.com/jira/browse/ENVERS-15 but thought I'd comment here as well.

      Maybe the problem stems from me not using Hibernate (or envers extension) to generate my schema.

      My classes have joined annotated as:

       @ManyToOne(cascade = {CascadeType.ALL})
       @JoinColumn(name = "contact_mech_id", referencedColumnName = "contact_mech_id", nullable = false, insertable = true, updatable = true)
       public ContactMech getContactMech() {
       return contactMech;
       }
      


      so that the column name is contact_mech_id, however envers generates the mapping to be contactMech_contact_mech_id instead.

      After walking through the code and trying to work out whats going on, changing org.jboss.envers.metadata.VersionsMetadataGenerator#addToOne to use:

      Column column = (Column) property.getValue().getColumnIterator().next();
      IdMapper relMapper = new SingleIdMapper(property.getName(), column.getName());
      


      instead of the prefixed version things started to work again (which revealed some other issues, which I'll post separately).

      Obviously this is a rather hackish alteration. Ideally I'd like to keep my column names in the versions table consistent with my normal table, so I wondering if there was any particular reason for the current behaviour?