Hibernate Removes too much Whitespaces
Description
Activity
BastiBl February 26, 2024 at 11:07 AM
Our problem is the same as in . We have many old applications which may use this “feature”.
According to the other ticket, we override those methods/functions in an own dialect.
The solution with supportsOrdinalSelectItemReference()
set to false is working properly.
I thought that the decimal-seperator is according to the country (i’m an engineer, not database oparator), but I understand the point of view.
BastiBl February 26, 2024 at 10:34 AM
Thank you for your answer
Christian Beikov February 26, 2024 at 10:25 AM
This has nothing to do with your country but is a setting in your DB2 server. The issue that is about this same problem refers to the DB2 documentation that explains the setting which controls this behavior:
I don’t know what to tell you, but every SQL database out there uses the .
as decimal separator in their SQL language, because that is standard and unambiguous. There are tons of potential problems when using ,
as decimal separator since it is ambiguous with the function argument and clause item separator as you see for yourself.
Since you as a developer are in control of the SQL that you write, this should not be a problem though. Just change disable this IMO insane DB2 setting and use .
as your decimal separator consistently.
BastiBl February 22, 2024 at 2:10 PM
We’re in Germany, and in Germany the decimal seperator as a comma is the standard.
The same happens when using SUBSTR
OR SUBSTRING
-Function. So the solution is, that Hibernate does not work with DB2 in Germany? And other lands, where decimal seperator is comma?
Christian Beikov February 22, 2024 at 1:25 PM
A different Jira issue with the same underlying problem has been brought up in the past and we rejected it just like we reject it again this time. This DB2 configuration turns SQL literals into something that is non-standard, and we don’t support that. Please just don’t use this DB2 configuration that makes a comma ,
be the decimal separator.
You can create a custom dialect and override supportsOrdinalSelectItemReference()
to disable the rendering of ordinal select item references if you can’t change the DB2 configuration.
If I execute a query like this:
Hibernate removes ALIAS and generates Query:
Now we order by Table-Column 2, but there’s no space between “2” and “,ID”, so the driver thinks we want to order by the numeric value 2,id which is not numeric, so the query cancels.
In our case, DB2 returns: DB2 SQL Error: SQLCODE=-103, SQLSTATE=42604, SQLERRMC=2,ID