Hello I am trying to get rows using Groovy Sql connection but it returns me records as a List inside a List. The following:
Sql sql = new Sql(dataSource)
List<GroovyRowResult> row = sql.rows('select * from user where username=:userName and password=:password, [userName:'groovy',password:'123'])
returns the result as [[return record as map]]
Any one help me to figure out why the result is a List inside a List. How will I get it as a single level List using the rows method?
It doesn't return a
Listinside aList, it returns aListofMapwith each map containing the columns selected from your select.So if you want all of the
usernames selected (as a List), you can just do:If you just want a single row, you can do:
And then this will effectively just be a map with each
keybeing the field name selected, and eachvaluebeing the value of the first row of each field