0

I want to write a totally dynamic query method, which gets dinamically column names as parameters. Column names i.e : id, age, name, etc. I'm going to use criteria query, however I don't know how it's done exactly.

Some example says:

"Path<Long> idPath = personRoot.get( Person_.id );
Path<Integer> agePath = personRoot.get( Person_.age );
criteria.select( builder.array( idPath, agePath ) );"

My problem is the usage of "builder.array" part. How can I put together my (i.e:) path elements into a "Selection... selections" parameter in order to the "select" accept it and be valid my dynamic query?

Is there any possibility to write multiple group by according to my "Selection... selections" parameter in the "select" part?

Any hints appreciated, thank You in advance.

SzGyD
  • 88
  • 7

1 Answers1

0

Selection... selections is just syntactic sugra for Selection[] selections. So you just need to create an array of selections, and pas this array as argument to the builder.array() method.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255