When using projection on properties, the result is returned as a list with elements in the same sequence as in the forecast block. At the same time, property names are not in the list, and this is really disadvantageous for the developer, since the result will be transmitted together, and the caller needs to know what value belongs to which property. Is there a way to return a map from a Criteria request with the property name as the key to the value?
so, the following code:
def c = Trade.createCriteria() def remicTrades = c.list { projections { property('title', 'title') property('author.name', 'author') } def now = new Date() between('publishedDate', now-365, now) }
This returns:
[['book1', 'author1']['book2', 'author2']]
Instead, I would like it to return:
[[book:'book1', author:'author1'][book:'book2', author:'author2']]
I know that I can organize this path after receiving the result, but I sincerely believe that the property alias should have been used by the criteria to return a list of a map that imitates the result of an SQL query, not a list. / P>
grails gorm createcriteria
rks
source share