Hello dear community,
I have a problem with accessing an array element directly after creating it when using the criteria API.
Here a simple example:
query.orderBy(
builder.asc(
builder.arrayGet(
builder.arrayAgg(null, root.get<String>("name")),
1
)
)
)
This generates the following ORDER BY clause
ORDER BY array_agg(e1_0.name)[1]
The problem is, this cause an error “ERROR: syntax error at or near “[”” because there are no parentheses around the array creation. A correct example would look like this:
ORDER BY (array_agg(e1_0.name))[1]
Is there a way to access the array correctly?