Kushal Kushal - 27 days ago 6
MySQL Question

SEPARATOR keyword not working properly in Hibernate Formula

I have following Hibernate forumla query, which I am able to execute in mysql workbanch.

select group_concat(distinct t.column_1_name SEPARATOR ', ') from table_name t and t.fk_record_id = record_id

While executing this query with Hibernate, hibernate is appending parent table to the SEPRATOR key word as shown in the below query.

select group_concat(distinct t.column_1_name parent_table.SEPARATOR ', ') from table_name t and t.fk_record_id = record_id

Here hibernate is not treating SEPRATOR as keyword. Anyone has any idea about this?

Answer Source

You can add SEPARATOR as keyword. Implement your own DialectResolver and add the keyword in lower case to the resulting dialect:

public class MyDialectResolver extends StandardDialectResolver {

  protected Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLException {
    Dialect dialect = super.resolveDialectInternal(metaData);
    return dialect;


You will then have to tell Hibernate to use your dialect resolver. For example in JPA you can do this in your persistence.xml:

    <property name="hibernate.dialect_resolvers" value="mypackage.MyDialectResolver"/>

Btw: The same applies to aggregating functions in other dialects. For example in Oracle the WITHIN keyword is missing.