SEPARATOR keyword not working correctly in Hibernate Formula

I have the following Hibernate forumla query that I can execute in mysql workbanch.

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

When executing this query with Hibernate, hibernate adds the parent table to the SEPRATOR keyword, as shown in the following 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 does not treat SEPRATOR as a keyword. Does anyone know about this?

+4
source share
1 answer

Keyword SEPARATORcan be added. Enter your own DialectResolverand add a lowercase keyword to the resulting dialect:

public class MyDialectResolver extends StandardDialectResolver {

  protected Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLException {
    Dialect dialect = super.resolveDialectInternal(metaData);
    dialect.getKeywords().add("separator");
    return dialect;
  }

}

Hibernate, . , JPA persistence.xml:

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

Btw: . , Oracle WITHIN.

+2

Source: https://habr.com/ru/post/1608267/


All Articles