我有一个arraylist,我想进行查询
def teams = province.competitions.teams
def fromTansfer = Transfer.withCriteria {
'in'("teamOld",teams)
eq("time", 0)
eq("year", 2014)
order("teamOld", "desc")
}
团队的结果是2D arraylist,withCriteria在in语句中有问题:
团队:
TransferController [[FC Munderfing, USV Raiffeisen Eggelsberg/Moosdorf, FC Münzkirchen, Union Stampfl-Bau Ostermiething, Union Peuerbach, Union CARIBAS Diersbach, Union VTA Rottenbach, Union Ziegelwerk], [...], [...]]
我认为Arraylist是2D的问题。我如何在一维转换它?
错误是:
caused exception: IllegalArgumentException occurred calling getter of test.Team.id
我该如何解决?
解决方案:
def teams = province.competitions.teams.flatten()
Thx joe69
答案 0 :(得分:2)
如果teams
是列表列表,并且您希望将所有内容展平为1个大列表,请致电teams.flatten()
。