|
CriteriaBuilder.treat statement generates SQL that does not put quotes around String discriminator values.
The generated SQL code has quotes only around last discriminator value, in my case around 'hrSignatureRequested'.
The discriminator column is declared this way: @DiscriminatorColumn(name = "classname", discriminatorType = DiscriminatorType.STRING, length = 1024)
Before Hibernate 4.3.1, the discriminator column was ignored and the generated SQL used integer constants instead of strings and the query worked as expected.
I think the fix should not be very difficult, yet I failed to find exactly where the quotes should be generated in the source code of hibernate.
Here is a part of generated SQL:
select distinct casestarte0_.id as col_0_0_, casestarte0_.id as col_1_0_ from public.hrCaseStarted casestarte0_ inner join public.CaseStarted casestarte0_1_ on casestarte0_.id=casestarte0_1_.id inner join public.AbstractEvent casestarte0_2_ on casestarte0_.id=casestarte0_2_.id left outer join .... where ( events1_.removed is null ) and ( upper(events1_11_.lastName) like upper ) and ( casestarte0_.id is not null ) and case when casestarte0_4_.id is not null then hrSignatureRequested when casestarte0_3_.id is not null then hrFormCreated when casestarte0_.id is not null then 'hrCaseStarted' end=? and ( casestarte0_2_.removed is null ) group by casestarte0_.id , casestarte0_.id order by casestarte0_.id asc
|