JPQL TYPE(...) function does not get qualified in SQL

Description

Four TABLE_PER_CLASS entities:

  • Base1

  • Child1 extends Base1

  • Base2

  • Child2 extends Base2

whereas Base1 holds a reference to Base2.

When searching for Base1 and sorting after Base2:

select e.id, TYPE(e),... from Base1 e
order by e.base2Reference.someBase2Attr DESC

This leads to the following error:

Caused by: org.h2.jdbc.JdbcSQLException: Ambiguous column name "CLAZZ_"; SQL statement:

The problem lies in the genated SQL query where no qualifier is used to access the clazz column (just clazz_ as col_1_0_):

select tablepercl0_.id as col_0_0_, clazz_ as col_1_0_, ....

And since we join to another table per class entity, there are two select clazz__ columns around.

Activity

Duplicate

Details

Assignee

Reporter

Components

Priority

Created September 28, 2015 at 1:07 PM
Updated November 29, 2017 at 6:57 AM
Resolved November 29, 2017 at 6:57 AM