Seam - 实体查询 - 动态限制
我有一个由Seam-gen 为实体Address
生成的EntityQuery - addressList
。
假设该地址具有以下字段:streetName
和 city
,因此 Seam-gen 会为它们生成限制。
我想通过以下限制扩展我的 EntityQuery: 我有一个字段“keyVal”,可以使用 #{addressList.keyVal}
在面孔上下文中设置。 假设keyVal
是aaa bbb ccc
。现在查询应该添加限制,用于查找所有实体:
streetName like '%aaa%' or streetName like '%bbb%' or streetName like '%ccc%'
or city like '%aaa%' or city like '%bbb%' or city like '%ccc%'
您对如何实现此目标有什么建议吗?我真的被困住了。
I have an EntityQuery - addressList
generated by Seam-gen for Entity Address
.
Lets say that address has following fields : streetName
and city
, so Seam-gen generate restrictions for them.
I would like to extend my EntityQuery with a following restrictions:
I have a field 'keyVal' which can be set in faces context with #{addressList.keyVal}
.
Lets supose that keyVal
is aaa bbb ccc
. Now the query should add restrictions which will be used to find all entities with:
streetName like '%aaa%' or streetName like '%bbb%' or streetName like '%ccc%'
or city like '%aaa%' or city like '%bbb%' or city like '%ccc%'
Do you have any suggestions how to achieve this? I am really stucked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 EntityQuery 不支持限制上的多个值绑定。看
https://issues.jboss.org/browse/JBSEAM-1065
您可以解决此问题有时,这可以通过创造性地使用您的标准类来实现。
有时您可以考虑修改查询。例如,如果我有一个员工姓名输入,并且我需要查询员工名字(如输入)或员工姓氏(如输入),我可以这样编写查询:
希望这能给您一些想法。
The problem is EntityQuery does not support multiple value bindings on restrictions. See
https://issues.jboss.org/browse/JBSEAM-1065
You can work around this sometimes by creative use of your criteria class.
You can sometimes look at modifying the query. For example, if I have a single staffName input and I need to query where staff first name like the input OR staff last name like input, I can write my query like this:
Hopefully this gives you some ideas.