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+?