Component.sortProperties() reorders Envers originalId key, breaking joined audit-table FK/joins for JOINED inheritance

When Envers is used with a JOINED inheritance hierarchy, it can reorder the audit table composite key columns, and causes joined audit-table reads to fail. Created an issue in tracker Jira

Thanks for the report. Can you please also try with the latest Hibernate ORM version and ideally create a reproducer based on our test case template?

Hi @beikov , Thanks for the response

I retested this with newer Hibernate ORM versions and can still reproduce it.

Tested versions:

  • 6.6.49.Final
  • 7.3.1.Final

The issue still occurs on both versions.

I also created a standalone reproducer based on the JPA test-case template, using H2: reproducer

Observed failure:

Unexpected result size. SQL: [select pav1_0.PTY_ID,pav1_0.REV_ID,pav1_1.FULL_NAME,pav1_0.FIRST_NAME,pav1_0.LAST_NAME from PERSON_AUD pav1_0 join PARTY_AUD pav1_1 on pav1_0.PTY_ID=pav1_1.REV_ID and pav1_0.REV_ID=pav1_1.PTY_ID order by pav1_1.REV_ID]

So the standalone reproducer shows the same problem:

  • JOINED inheritance
  • Envers audit tables
  • read-only audit view entities with inherited @IdClass
  • generated join between PERSON_AUD and PARTY_AUD uses swapped columns

Expected join:

… on pav1_0.PTY_ID=pav1_1.PTY_ID and pav1_0.REV_ID=pav1_1.REV_ID

Actual join:

… on pav1_0.PTY_ID=pav1_1.REV_ID and pav1_0.REV_ID=pav1_1.PTY_ID

Awesome, please create a Jira ticket for this and post the link here.

Bug was already created for this. HHH-20357
Let me know if I need to create another one @beikov
Thanks!

I see that you also added a reproducer on the Jira ticket now. Thanks for that. We’ll try to look into it as soon as possible.

I see the fix has been released. Thanks for addressing this @beikov . Would it be possible to backport this fix to the 6.x as well? We are not planning to migrate to Boot 4 in the near future and would greatly appreciate having it available in 6.x.

Sorry, but atm, we have no plans to backport this to 6.6, unless a Red Hat or IBM customer asks for this. We usually only port fixes to the last stable version, but Hibernate ORM 6.6 is in limited support mode. If you need long term support for that version, then please consider the commercial support options.