0

I have tried using a number of MySQL functions in Spring with HQL that hibernate does not support, such as GROUP_CONCAT. Hibernate will produce the following error.

Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode 
 +-[METHOD_CALL] MethodNode: '('
 |  +-[METHOD_NAME] IdentNode: 'GROUP_CONCAT' {originalText=GROUP_CONCAT}
 |  \-[EXPR_LIST] SqlNode: 'exprList'
 |     \-[DOT] DotNode: 'propertyre1_.id' {propertyName=id,dereferenceType=PRIMITIVE,getPropertyPath=id,path=property.id,tableAlias=propertyre1_,className=com.mypackage.MyClas,classAlias=property}
 |        +-[ALIAS_REF] IdentNode: 'propertyre1_.id' {alias=property, className=com.mypackage.MyClass, tableAlias=propertyre1_}
 |        \-[IDENT] IdentNode: 'id' {originalText=id}

However, I have found that hibernate can be configured to accept custom functions by adding to the hibernate configuration with ...

hibernateConfiguration.addSqlFunction("group_concat", new StandardSQLFunction("group_concat", new StringType()));

I'm struggling though in finding a way to access the hibernate Configuration with Spring Boot & Spring 5+. I have found the following stackoverflow post, however this seems to be for an older version of spring as LocalSessionFactoryBean no longer has a method named postProcessConfiguration or any other obvious way to manipulate the configuration.

Is there any way to manipulate the hibernate configuration before the session factory has been built in Spring 5+?

3urdoch
  • 7,192
  • 8
  • 42
  • 58
  • Does https://stackoverflow.com/questions/2736100/how-can-i-get-the-hibernate-configuration-object-from-spring help? – M A Oct 03 '18 at 17:12

1 Answers1

1

The answer to this is exactly what you need:

https://stackoverflow.com/a/42486291/6709262

To use it with Spring Boot simply enable it in the application.(yml|properties):

spring.jpa.properties.hibernate.dialect = full.qualified.package.DialectName
Timo Reymann
  • 755
  • 5
  • 16
  • Yes. It seemes I went down a dead end with the Configuration approach, but this approach does work. – 3urdoch Oct 05 '18 at 20:05