Grails 标准构建器
我有以下内容:
class Store{
String name
}
class Shop{
String name
Store store
}
我的标准构建器:
def c = Shop.createCriteria()
def results = c.list {
like("name", "Harrods")
like("store.name", "McDonals")
}
我确信这是无效的,因为我已经测试过它。我如何设法使用 criteriaBuilder 并执行此操作:like("store.name", "McDonals")?
期待获得任何帮助, 约翰
I have the folowing:
class Store{
String name
}
class Shop{
String name
Store store
}
My criteria builder:
def c = Shop.createCriteria()
def results = c.list {
like("name", "Harrods")
like("store.name", "McDonals")
}
I'm sure this is invalid cause i'v tested it. How can i manage to use criteriaBuilder and do this: like("store.name", "McDonals")?
Looking forward to get any help,
John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您正在查询关联,请尝试:
这将在 name 和 store.name 之间执行联合查询。
Since you're querying an association, try:
This will do an conjoined query between name and store.name.
查看 documentation 看起来您需要为 like 子句使用
%
。Check out the documentation Looks like you need to use a
%
for your like clause.