问题描述
我使用EasyGrid插件,并且必须找到其中整数字段如'%001%'的值
initialCriteria {
ilike('id',%+ params.id +%)
}
但ilike不适用于Integer。
我试过: {
ilike('id'.toString(),%+ params.id +%)
}
initialCriteria {
ilike('str id)',%+ params.id +%)
}
但如果 id
是数据库中的一个整数,那么它就不起作用了。 ,那么 ilike
并没有多大意义,并且可能有更好的方法来做你正在尝试做的事情(比如向域对象添加一个类型字段或其他东西,并按类型过滤)
然而,你应该可以做这样的事情(未经测试):
initialCriteria {
sqlRestrictioncast(id AS char(256))like'%001%''
}
I use EasyGrid plugin and must find values where integer field like '%001%'
initialCriteria {
ilike('id', "%"+params.id+"%")
}
But ilike doesn't work with Integer. How to do it?
I tried to do:
initialCriteria {
ilike('id'.toString(), "%"+params.id+"%")
}
initialCriteria {
ilike('str(id)', "%"+params.id+"%")
}
but it's not work.
If id
is an integer in the database, then ilike
doesn't really make much sense and there is probably a better way to do what you are trying to do (like adding a type field or something to the domain object, and filter by type)
However, you should be able to do something like this (untested):
initialCriteria {
sqlRestriction "cast( id AS char( 256 ) ) like '%001%'"
}
这篇关于如何在Integra中使用ilike在grails中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!