Hi,
during the upgrade, I encountered that some SQL statements don’t work anymore. For example:
SELECT s.id FROM Table s WHERE (:findDeleted = true OR s.deleted = false)
Before the upgrade, the SQL statement is translated into this:
select table0_.id as id1_132_0_ from Table table0_ where (?=1 or table0_.deleted=0)
After the upgrade, the SQL statement is translated into this:
select s1_0.id from SkupinaStravniku s1_0 where (?=true or s1_0.deleted=0)
And throw this error: Dynamic SQL Error; SQL error code = -206; Column unknown; TRUE; At line 1, column 32 [SQLState:42S22, ISC error code:335544578]
You can see that I use BooleanToInt Converter but I don’t know why the true keyword is not translated into 1. I use the Firebird 2 database which does not support the boolean type, so true is interpreted as a column name that does not exist.
Then I updated the SQL statement:
SELECT s.id FROM Table s WHERE (:findDeleted = 1 OR s.deleted = false)
The Hibernate throws this exception: Parameter value [false] did not match expected type [basicType@3(java.lang.Integer,4) ]
Finally, I updated the SQL once more:
SELECT s.id FROM Table s WHERE (cast(:findDeleted as integer) = 1 OR s.deleted = false)
This works but it is a bit nasty solution (converting the boolean named parameter and value in SQL statement to Integer).
The second example is this:
SELECT c.id FROM Table c WHERE true = ANY(SELECT d.visibility FROM Table d WHERE d.table = c)
Before the upgrade, the SQL statement is translated into this:
select table0_.id as id1_12_ from Table table0_ where 1=any (select table20_.visibility from Table2 table20_ where table20_.table_id=table0_.id)
But after the upgrade, the true keyword is not translated into 1. If I substitute 1 for true, the SQL works as expected.
What is the supposed solution for the SQL statements?