Summary
Hibernate ORM 6.6.49.Final currently hardcodes the separator used when rendering SQL value lists (typically “,”).
For some database configurations, SQL statements rendered without a customizable separator may not be accepted by the database parser.
We would like Hibernate to provide an extension point allowing dialects or custom translators to customize list separators (for example ", " instead of “,”).
Context
We are using:
- Hibernate ORM 6.6.49.Final
- IBM Db2 for z/OS
- A Db2 configuration where decimal numbers use a comma (,)
Examples of generated SQL fragments:
VALUES (1,2,3)
IN (?,?,?,?,?,?,?)
COALESCE(COL1,999999)
In our environment, IBM Db2 for z/OS is configured with a comma (,) as the decimal separator.
In our Db2 for z/OS configuration, SQL statements rendered without a space after list separators are rejected by the Db2 parser, whereas the same statements are accepted when rendered using ", ".
Adding a space after the comma resolves the issue.
We understand that Hibernate’s current behavior may be correct for the vast majority of databases and configurations. Our request is not to change the default rendering, but to make this formatting aspect customizable.
Historically, it was possible to customize parts of SQL rendering more easily in older Hibernate versions. Since the SQL AST architecture introduced in Hibernate 6, the separator rendering logic appears to be internal and not overridable.
Current Limitation
The issue is not necessarily the default separator itself.
The issue is that:
- Hibernate always renders separators using an internal hardcoded value.
- There is currently no public SPI allowing customization.
- Custom dialect implementations cannot influence this rendering behavior.
- SQL AST translators cannot easily override this specific formatting concern.
Requested Enhancement
Introduce a protected or configurable hook allowing customization of SQL separators during SQL rendering.
Possible examples:
protected String getListSeparator() {
return ", ";
}
or
protected void appendListSeparator(SqlAppender appender) {
appender.appendSql(", ");
}
or a Dialect-level configuration:
public String getSqlListSeparator() {
return ", ";
}
Expected Benefits
This would:
- Preserve current behavior by default.
- Maintain backward compatibility.
- Allow database vendors and custom dialects to adapt SQL rendering when required.
- Improve Hibernate extensibility without impacting existing users.
- Avoid maintaining custom Hibernate forks for very small formatting customizations.
Additional Notes
This request is not asking Hibernate to change the default SQL rendering behavior.
The request is only to expose an official extension point so that applications and dialect implementations can customize separator rendering when required by specific database environments.
Thank you for considering this enhancement.