Felix Janssen (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjE0MGJjZGQ1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16521?atlOrigin=eyJpIjoiMjE0MG...
) HHH-16521 (
https://hibernate.atlassian.net/browse/HHH-16521?atlOrigin=eyJpIjoiMjE0MG...
) Regression with target type in CAST function (
https://hibernate.atlassian.net/browse/HHH-16521?atlOrigin=eyJpIjoiMjE0MG...
)
Issue Type: Bug Affects Versions: 6.0.0 Assignee: Unassigned Components: hibernate-core
Created: 26/Apr/2023 04:50 AM Priority: Major Reporter: Felix Janssen (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
When writing a HQL query with a CAST function to a nationalizes string, there is different
behavior between Hibernate 5 and Hibernate 6, with property
hibernate.use_nationalized_character_data set to true.
HQL:
[...] CAST ( name AS nstring) [...]
Oracle SQL (Hibernate 5)
[...] CAST ( name AS nvarchar2(4000)) [...]
Oracle SQL (Hibernate 6)
[...] CAST ( name AS varchar2 (4000)) [...]
So in Hibernate 5, cast to nstring would produce the nationalized type nvarchar2(4000) and
in Hibernate 6, it will produce the non-nationalized type varchar2(4000).
I would expect a cast to nstring to produce a cast to nvarchar2(4000) in (Oracle) SQL,
just like in Hibernate 5.
*Cause*
In BaseSqmToSqlAstConverter , there is a method visitCastTarget that decides on the SQL
type for the cast.
It uses InferredBasicValueResolver.resolveSqlTypeIndicators with an nstring as
'resolved'. This causes the code path to eventually jump to
NVarcharJdbcType.resolveIndicatedType , which will produce Types.VARCHAR , because
indicators.isNationalized() returns false. indicators here is a StandardSqmTranslator ,
which doesn't provide an overridden method for isNationalized.
(
https://hibernate.atlassian.net/browse/HHH-16521#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16521#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100223- sha1:038ca59 )