Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-5123

HHH-8280 - Envers ValidityAuditStrategy does not handle composite or business keys

XMLWordPrintable

    • Hide

      Create an entity with a business or composite key, persist it, un-persist it, then attempt to re-persist it (using the same key).

      Show
      Create an entity with a business or composite key, persist it, un-persist it, then attempt to re-persist it (using the same key).

      The ValidityAuditStrategy only updates the revend value when the revision type is not add.

      // Update the end date of the previous row if this operation is expected to have a previous row
      if (getRevisionType(auditCfg, data) != RevisionType.ADD) {
      ...
      }

      This assumes an entity uses a simple surrogate key (that is never re-used) and fails to update the revend with an error since it finds more than one row:

      if ( rowCount != 1 )

      { throw new RuntimeException( "Cannot update previous revision for entity " + auditedEntityName + " and id " + id ); }

      Because of this flaw, this strategy cannot be used for business keys or composite keys (or any scenario where the id might be re-used on re-persist).

              gbadner@redhat.com Gail Badner (Inactive)
              ben.bonnell Benjamin Bonnell (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: