Hibernate 5.4.10 (HH-12895 ) Regression

HH-12895 - Regression

Hello! With the changes in the above mentioned bug fix, it has broken existing code. In my scenario, the projection that was removed was necessary because the attributes are on the joined subtable and not the parent. I have 2 entities with JOINED_SUBTABLE inheritance (Resource and Issuer). When the following query is executed in 5.4.10.Final it fails as it does not scan the joined subtable properly.

@NamedQuery(name = IssuerImpl.SELECT_RESOURCES_BY_ISSUER, query = “SELECT resource.identifier FROM " + ResourceImpl.ENTITY_NAME + " resource WHERE resource.identifier.issuer IN (SELECT issuer.identifier.issuer FROM " + IssuerImpl.ENTITY_NAME + " issuer WHERE issuer.parentIssuer = :issuer OR issuer = :issuer)”),
When the query is executed, Hibernate now logs an error:

[ERROR] 2019-12-10 11:37:20.658 [AllScenarioTests Group-1-Thread-3] SqlExceptionHelper - user lacks privilege or object not found: ISSUERIMPL1_1_.PARENT_ISSUER in statement [select resourceim0_.ISSUER as col_0_0_, resourceim0_.IDENTIFIER as col_0_1_ from RESOURCES resourceim0_ where resourceim0_.ISSUER in (select issuerimpl1_.ISSUER from RESOURCES issuerimpl1_ where issuerimpl1_.ENTITY=‘IssuerImpl’ and (issuerimpl1_1_.PARENT_ISSUER=? and issuerimpl1_1_.PARENT_IDENTIFIER=? or issuerimpl1_.ISSUER=? and issuerimpl1_.IDENTIFIER=?))]
[ERROR] 2019-12-10 11:37:20.658 [AllScenarioTests Group-1-Thread-3] SqlExceptionHelper - user lacks privilege or object not found: ISSUERIMPL1_1_.PARENT_ISSUER in statement [select resourceim0_.ISSUER as col_0_0_, resourceim0_.IDENTIFIER as col_0_1_ from RESOURCES resourceim0_ where resourceim0_.ISSUER in (select issuerimpl1_.ISSUER from RESOURCES issuerimpl1_ where issuerimpl1_.ENTITY=‘IssuerImpl’ and (issuerimpl1_1_.PARENT_ISSUER=? and issuerimpl1_1_.PARENT_IDENTIFIER=? or issuerimpl1_.ISSUER=? and issuerimpl1_.IDENTIFIER=?))]
[ERROR] 2019-12-10 11:37:20.658 [AllScenarioTests Group-1-Thread-3] SqlExceptionHelper - user lacks privilege or object not found: ISSUERIMPL1_1_.PARENT_ISSUER in statement [select resourceim0_.ISSUER as col_0_0_, resourceim0_.IDENTIFIER as col_0_1_ from RESOURCES resourceim0_ where resourceim0_.ISSUER in (select issuerimpl1_.ISSUER from RESOURCES issuerimpl1_ where issuerimpl1_.ENTITY=‘IssuerImpl’ and (issuerimpl1_1_.PARENT_ISSUER=? and issuerimpl1_1_.PARENT_IDENTIFIER=? or issuerimpl1_.ISSUER=? and issuerimpl1_.IDENTIFIER=?))]

In this case the prior JOIN was necessary to load the attributes off the subtable although it is not directly returning them.

Executing the code with 5.4.9.Final runs successfully.

The change broke the selection method for the child entity table. It is now looking at the parent table not the joined subtable. IE: It is looking at the parent RESOURCES tables instead of the ISSUERS table which the IssuerImpl is mapped to via the JOINED_SUBTABLE inheritance.

Hi @saroehr,

can you please open a Jira issue, it would be great if you could attach to it a reproducer.

Thanks