How to make a query criteria that concatenates 3 columns

0

I need to make a query in Criteria that concatenates 3 fields.

Example:

Criteria c = session.createCriteria(A.class, "A");
ProjectionList p = Projections.projectionList();
p.add(Projections.property("A.grupo"));
p.add(Projections.property("A.subgrupo"));
p.add(Projections.property("A.insumo"));
p.add(Projections.groupProperty("A.grupo"));
p.add(Projections.groupProperty("A.subgrupo"));
p.add(Projections.groupProperty("A.insumo"));
c = c.setProjection(p);
  List as= c.list();

so select returns an array of objects it has:

as[0]="A.grupo";
as[1]="A.subgrupo";
as[2]="A.insumo";

I need somehow concatenate these 3 fields so that the array looks like this

as[0]="a.grupo a.subgrupo a.insumo";

How do I do this?

sql equivalent:

SELECT CONCAT(a.grupo, ' ', CONCAT(a.subgrupo, ' ', a.insumo)) as firstlast 
FROM A a;
    
asked by anonymous 26.03.2018 / 20:33

0 answers