我尝试从链接下面的代码,它似乎工作得很好,万一将来链接被打破,我会粘贴代码。
保持简单保持微笑:)
import java.util.List;import org.hibernate.criterion.Restrictions;public class SplitHibernateIn { private static int PARAMETER_LIMIT = 999; public static org.hibernate.criterion.Criterion buildInCriterion(String propertyName, List values) { org.hibernate.criterion.Criterion criterion = null; int listSize = values.size(); for (int i = 0; i < listSize; i += PARAMETER_LIMIT) { List subList; if (listSize > i + PARAMETER_LIMIT) { subList = values.subList(i, (i + PARAMETER_LIMIT)); } else { subList = values.subList(i, listSize); } if (criterion != null) { criterion = Restrictions.or(criterion, Restrictions.in(propertyName, subList)); } else { criterion = Restrictions.in(propertyName, subList); } } return criterion; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)