Wrong SQL generated for HQL subquery referencing a superclass property in joined inheritance schema in Hibernate

Solution In Progress - Updated -

Issue

  • An entity (e.g. Employee) extends a superclass (Person) in an InheritanceType.JOINED hierarchy
  • A superclass property (e.g. Person.firstName) is referenced in an HQL subquery involving the subclass

    ... where exists (select employee from company.employees as employee where lower(employee.firstName) like :param1 ...
    
  • The generated SQL references a non-existent join (the subclass/superclass table join is missing but referenced)

    ... where exists (select employees1_.id from Employee employees1_ where ... lower(employees1_1_.firstName) ...
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6
    • 7
  • Hibernate
    • 4
    • 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.