|
For @Inheritance(strategy=InheritanceType.JOINED), three forms of polymorphic queries involving TYPE() generated bad SQL Statements involving outer joins.
These queries execute correctly for @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
EXAMPLE OF FAILURE:
e.g. for public static final String JPQL_QUERY_FIND_ALL_PERSONS_USING_IN = "SELECT p" + " FROM Party p" + " WHERE TYPE (p) IN (" + " Person" + " )";
The generated SQL fails as below:
Hibernate: select party0_.id as id2_1_, ... from Party party0_ left outer join Person party0_1_ on party0_.id=party0_1_.id left outer join Organisation party0_2_ on party0_.id=party0_2_.id where case when party0_1_.id is not null then Person when party0_2_.id is not null then Organisation when party0_.id is not null then 'Party' end='Person' Aug 23, 2014 2:26:43 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 42122, SQLState: 42S22 Aug 23, 2014 2:26:43 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: Column "PERSON" not found; SQL statement:
EXAMPLE PROJECT: Exported Eclipse m2e example project/test (source only) attached.
|