Given is the following JPQL-Query:
Code:
from AddressVersion a where type(a) = AddressInhouse
AddressInhouse is a subclass from AddressVersion.
The following error occurs:
Quote:
Caused by: org.h2.jdbc.JdbcSQLException: Feld "DOMESTIC" nicht gefunden
Column "DOMESTIC" not found;
The generated SQL, handling the type-operator, on
 H2-Database is:
Quote:
from
        ADDRESS_VER addressver0_ 
    left outer join
        ADDRESS_DOMESTIC addressver0_1_ 
            on addressver0_.ADDRV_ID=addressver0_1_.ADDO_ADDRV_ID 
    left outer join
       ADDRESS_FOREIGN addressver0_2_ 
            on addressver0_.ADDRV_ID=addressver0_2_.ADFO_ADDRV_ID 
    left outer join
        ADDRESS_INHOUSE addressver0_3_ 
            on addressver0_.ADDRV_ID=addressver0_3_.ADIH_ADDRV_ID 
    where
        case 
            when addressver0_1_.ADDO_ADDRV_ID is not null then DOMESTIC 
            when addressver0_2_.ADFO_ADDRV_ID is not null then FOREIGN 
            when addressver0_3_.ADIH_ADDRV_ID is not null then INHOUSE 
            when addressver0_.ADDRV_ID is not null then 'AddressVersion' 
        end='INHOUSE'
However, the discriminator-values in the case-statement should be treated as String (in hyphens)
Quote:
 when addressver0_1_.ADDO_ADDRV_ID is not null then 'DOMESTIC' 
            when addressver0_2_.ADFO_ADDRV_ID is not null then 'FOREIGN' 
            when addressver0_3_.ADIH_ADDRV_ID is not null then 'INHOUSE' 
            when addressver0_.ADDRV_ID is not null then 'AddressVersion' 
        end='INHOUSE'
Looks for me like a bug in the H2-Dialect.
Can somebody confirm this or give me some advice?
Thanks