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".
When you do this, are you manually creating the database schema? It seems Envers places the number and text fields as part of the primary key and therefore the not-null="false" is omitted and therefore the Envers schema gets created as follows:
create table category_item_r (rev_begin bigint not null, category_id bigint not null, number bigint not null, text varchar(255) not null, item_id bigint not null, rev_type tinyint, rev_end bigint, primary key (rev_begin, category_id, number, text, item_id))
While the ORM created table is as follows:
create table category_item (category_id bigint not null, item_id bigint not null, number bigint, text varchar(255), primary key (category_id, item_id))
Based on your mappings, we should likely be doing the same with the Envers audit table and creating the primary key as:
primary key ( rev_begin, category_id, item_id )
and marking the number and text fields as nullable per the not-null="false" mapping. |