I need to execute a SELECT with GROUP_CONCAT but I recieved this error all the time.
This is the query:
“select bk.categoria,GROUP_CONCAT(bk.nombre),GROUP_CONCAT(bk.id) from modelos.Productos as bk where bk.code=‘25416854168746541’ group by bk.categoria ORDER BY bk.categoria,bk.nombre ASC”
And this is the error:
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: ‘productos0_.Nombre’ {propertyName=nombre,dereferenceType=ALL,propertyPath=nombre,path=bk.nombre,tableAlias=productos0_,className=modelos.Productos,classAlias=bk}
| ±[ALIAS_REF] IdentNode: ‘productos0_.ID’ {alias=bk, className=modelos.Productos, tableAlias=productos0_}
| -[IDENT] IdentNode: ‘nombre’ {originalText=nombre}
Is possible use GROUP_CONCAT on hibernate queries?
You need to register the function so that Hibernate knows about it. Check out the MySQLDialect for an example of how you can register a function which you can do by extending the Dialect or via the bootstrapping mechanism.
This is the first time that I hear abour “functions”. I searched a tutorial on internet, but I dont find anything. The only thing that I find is something complicated with a class that extends from dialect, etc
This is the only option? Dont exist an easiest option?
That’s no longer supported. My answer is for 5.2 which is the latest version. For older versions, you need to check the 4.x source code and see whether you can do the same.