revisionFieldName overide causes invalid column aliases on many-to-many relationships

Description

Had a issue which took a good while to track down.

When using AuditReader.find(Entity.clas, id, revision) to pull back a revision of a entity a SQL exception was given with a non unique column alias on entities with a many-to-many field, other entites without manytomany worked.

It looks like the query was generating a duplicate '_revision' field without using an column alias. '_revision' was set using the property overide 'org.hibernate.envers.revisionFieldName=_revision' .

Below is a copy of the failing query:

After lots of debugging trying to create test cases based on my entity relationships which where passing without problem it occurred on the test project i'd not overiden 'org.hibernate.envers.revisionFieldName' . As soon as I set this property the test cases started failing. Removing this property from the original project, aliases are generated correctly and audited entities with many to many relatioships can now be retreivied. Below is the working sql generated with 'org.hibernate.envers.revisionFieldName' not set.

Environment

MySql5

Activity

Show:
Lukasz Antoniak
May 23, 2011, 6:35 PM

Could you please post your entity mappings, Envers configuration and execution of AuditReader.find() method? I was unable to reproduce this issue. Setting "org.hibernate.envers.revisionFieldName" to "_revision" in org.hibernate.envers.test.integration.manytomany.BasicSet test case produces valid SQL query. Example:

Brett Meyer
October 31, 2013, 3:11 PM

No response received

Assignee

Unassigned

Reporter

Adam Evans

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure