import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
public List<CmsTask> getHtmlTaskList(Boolean isIos) {
Session session = getSession();
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
CriteriaQuery<CmsTask> createQuery=criteriaBuilder.createQuery(CmsTask.class);
Root<CmsTask> root = createQuery.from(CmsTask.class);
Predicate queryCondition = criteriaBuilder.equal(root.get("htmlTask"), true);
queryCondition.equals(criteriaBuilder.equal(root.get("disabled"), false));
if(null==isIos || isIos) {
//iosShow是CmsTask中的字段
queryCondition.equals(criteriaBuilder.equal(root.get("iosShow"), true));
}else {
queryCondition.equals(criteriaBuilder.equal(root.get("androidShow"), true));
}
return session.createQuery(createQuery.where(queryCondition)).getResultList();
}
protected Session getSession() {
return sessionFactory.getCurrentSession();
}