gpt4 book ai didi

grails - Grails-如何将值列表传递给域类

转载 作者:行者123 更新时间:2023-12-02 15:35:41 25 4
gpt4 key购买 nike

我正在尝试使用Grails实现以下SQL。

“Select * from table1 where col1=’COL1’ and col2  in(‘COL2_1’,’COL2_2’,….) and col3=1”

我可以获取col2映射,但不确定如何将该映射传递到table1域

我尝试这样的事情
table1.findAllWhere(col1:'COL1', col2 :modelMap.COl2, col3:1)

这将返回null。

我对此表示感谢

谢谢
巴拉

最佳答案

您可以直接将HQL用于此:

Map params = [col1: 'COL1', col2List: ['COL2_1', 'COL2_2', 'COL2_3'], col3: '1']

TableOne.executeQuery("""
select t1
from TableOne t1
where t1.col1 = :col1 and t1.col2 in (:col2List) and t1.col3 = :col3
""", params)

关于grails - Grails-如何将值列表传递给域类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11303820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com