QueryDSL: Unsupported expression sum -


i have bean object:

@entity @table(name="a_table") public class {  @id @generatedvalue(strategy = generationtype.auto) private long id;  @column(name="amount") private int amount;  @manytoone private b b;  @manytoone private c c;  public municipalityinventory(int amount, b b, c c) {     this.amount = amount;     this.b = b;     this.c = c; } 

i try bind query result object above. first try querydsl (it worked in sense presentation of data correct, didn't bind property's of query object, because returned tuple contained stringpath, numberexpression , other weird data types me)

public list<tuple> findall(){     qa = qa.a;     qb b = qb.b;     qc c = qc.c;      jpaquery query = new jpaquery(entitymanager);      return query.from(a)             .innerjoin(a.b, b)             .innerjoin(a.c, c)             .orderby(c.name.asc())             .groupby(c.name, a.c, c.name)             .list(a.amount.sum(), b.name, c.name); } 

as said worked, trying convert example (oh, , new condition in groupby needed compile) can work right away proper object:

    return query.from(a)             .innerjoin(a.b, b)             .innerjoin(a.c, c)             .orderby(b.name.asc())             .groupby(c.name, a.amount, b.id, c.id)             .list(projections.fields(a.class, a.amount.sum(), b, c)); 

when compiling give error warning

java.lang.illegalargumentexception: unsupported expression sum(a.amount)     @ com.mysema.query.types.qbean.createbindings(qbean.java:70) 

why's that? understanding should work.

querydsl can't determine sum() expression field of want populate.

use alias define target field:

a.amount.sum().as("fieldname") 

querydsl can handle paths , alias expressions when binding fields or properties.


Comments

Popular posts from this blog

c# - ajax - How to receive data both html and json from server? -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -