An internal Envers Query on historic data triggers a QueryException when navigating a ternary association mapped as "map" with an entity as key and a value object as value mapped as composite-element.
The following example might help to understand the problem:
Assume the collection property is:
Where Item is an entity and Value is a value object with several properties.
The XML mapping then looks like:
The query created by Envers triggering the exception is:
When I map the collection using a CompositeUserType, the query works and I can navigate the association (but then I get a problem with nullable properties in the composite user type, because Envers creates a SQL where clause with checks for "property=null" instead of "property is null". Perhaps I should write another bug report for this issue, too?)
For a full description see <https://developer.jboss.org/thread/275323>
Here I also describe the second problem with nullable properties.
The attached tar archive contains a complete test case for both problems. See JUnit test case CategoryTest, first.
There are two boolean variables you can set to demonstrate either the "QueryException" or the "nullable property" problem. You will have to modify the mapping document Category.hbm.xml to demonstrate the QueryException problem as by default I have the CompositeUserType workaround enabled.
The tar archive also contains a DDL SQL script for the required test database. It should work with a PostgreSQL RDBMS out of the box. You will have to modify persistence.xml for your DB environment.