我有一个表,其中包含一个由逗号分隔的字符串字段,并且我有一个字符串数组。我想在字符串数组中查看这个逗号分隔的字符串字段。我无法标记字符串字段,以便我可以通过“IN”子句查看字符串数组。示例如下:
String feild = "inbox, outbox, draft, sent";
String[] strArray = ["inbox, "outbox", "sent", "web", "software"];
如何获取feild字符串与字符串数组的交集?
最佳答案
您可以使用:
Criterion c = null;
for(String s : strArray){
if(c!=null){
c = Restrictions.like("field","%"+s+"%");
else {
c = Restrictions.or(c,Restrictions.like("field","%"+s+"%"));
}
}
这是一种低效的方式,但却是一种解决方案。
关于java - hibernate 中字符串字段与字符串数组的交集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24372073/