GROUP_CONCAT does NOT work in QueryDSL
See original GitHub issueHi there,
I am struggling to figure out how to use ‘GROUP_CONCAT’ in QueryDSL.
final QDataSourceSmallEliminate eliminate = QDataSourceSmallEliminate.dataSourceSmallEliminate;
final QLattitudeVisitor lattitude = LattitudeVisitorServiceImpl.$;
// Expressions.stringOperation(SQLOps.GROUP_CONCAT, lattitude.tagName)
return QuerydslUtils.newQuery(entityManager).select(Projections.constructor(EliminateLattitude.class,
eliminate.id,
JPAExpressions.selectDistinct( SQLExpressions.groupConcat(lattitude.tagName)).from(lattitude).where(lattitude.urlCrc.eq(eliminate.urlCrc))))
.from(eliminate)
.fetch();
Exception:
org.springframework.dao.InvalidDataAccessApiUsageException: No pattern found for GROUP_CONCAT; nested exception is java.lang.IllegalArgumentException: No pattern found for GROUP_CONCAT
...
Caused by: java.lang.IllegalArgumentException: No pattern found for GROUP_CONCAT
at com.querydsl.core.support.SerializerBase.visitOperation(SerializerBase.java:280)
at com.querydsl.jpa.JPQLSerializer.visitOperation(JPQLSerializer.java:437)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:231)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:31)
at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83)
at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92)
at com.querydsl.jpa.JPQLSerializer.serialize(JPQLSerializer.java:203)
at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:358)
at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:39)
at com.querydsl.core.types.SubQueryExpressionImpl.accept(SubQueryExpressionImpl.java:57)
at com.querydsl.core.support.FetchableSubQueryBase.accept(FetchableSubQueryBase.java:150)
at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92)
at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:119)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:225)
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:31)
at com.querydsl.core.types.ConstructorExpression.accept(ConstructorExpression.java:112)
at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92)
at com.querydsl.jpa.JPQLSerializer.serialize(JPQLSerializer.java:203)
at com.querydsl.jpa.JPAQueryBase.serialize(JPAQueryBase.java:60)
at com.querydsl.jpa.JPAQueryBase.serialize(JPAQueryBase.java:50)
at com.querydsl.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:98)
at com.querydsl.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:94)
at com.querydsl.jpa.impl.AbstractJPAQuery.fetch(AbstractJPAQuery.java:201)
at com.moraydata.general.secondary.repository.impl.DataSourceSmallEliminateRepositoryImpl.findObject(DataSourceSmallEliminateRepositoryImpl.java:98)
at com.moraydata.general.secondary.repository.impl.DataSourceSmallEliminateRepositoryImpl$$FastClassBySpringCGLIB$$b42d875d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
QueryDSL 4.2.1 & JDK1.8 & Spring Boot2.0 & MySQL 5.7.
I read through the latest reference doc still cannot find the answer, so what should I do to make it work ?
Please help. Thanks in advance. @Shredder121
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Group concat equivalent in queryDSL - java - Stack Overflow
I am using queryDSL with spring JPA, and it is updated to the latest version, and I was not able to find such...
Read more >GroupConcat equivalent in SQLSubquery querydsl
Hi all I am using nested quries in query dsl. One of the subquery is returning a single column. I want to concat...
Read more >QueryDsl QuerydslRepositorySupport에서 group_concat사용 ...
출처 https://github.com/querydsl/querydsl/issues/2377 · GROUP_CONCAT does NOT work in QueryDSL · Issue #2377 · querydsl/querydsl.
Read more >Uses of Interface com.querydsl.core.types.Expression
Wrap a Querydsl expression into a Guava function ... Create a left is not null expression ... Get a group_concat(expr, separator) expression.
Read more >Criteria API for JPA backends - Blaze Persistence
When you work with Querydsl you can additionally have first class integration by using the ... Some features like CTEs simply can not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@beamofsoul
if you use spring boot data jpa and
querydsl-jpa
, You can follow these stepsIn JPA this is unsupported. You’ll have to ask your ORM vendor to implement it first (for example Hibernate).
You could consider using the
blaze-persistence-querydsl
extension to fill the gap: https://persistence.blazebit.com/documentation/1.5/core/manual/en_US/index.html#querydsl-integrationWhich has the following methods:
JPQLNextExpressions.groupConcat(Expression<?> expression, String separator, OrderSpecifier<?>... orderSpecifiers)
JPQLNextExpressions.groupConcat(Expression<?> expression, Expression<String> separator, OrderSpecifier<?>... orderSpecifiers)
JPQLNextExpressions.groupConcat(boolean distinct, Expression<?> expression, String separator, OrderSpecifier<?>... orderSpecifiers)
JPQLNextExpressions.groupConcat(boolean distinct, Expression<?> expression, Expression<String> separator, OrderSpecifier<?>... orderSpecifiers)