public static boolean isManagerTypeUsed(String managerType, EntityManager em) {
try {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq;
Root<?> from;
cq = cb.createQuery(Long.class);
from = cq.from(ApplianceManagerConnector.class);
cq = cq.select(cb.count(from))
.where(cb.equal(from.get("managerType"), managerType));
Long count1 = em.createQuery(cq).getSingleResult();
cq = cb.createQuery(Long.class);
from = cq.from(Appliance.class);
cq = cq.select(cb.count(from))
.where(cb.equal(from.get("managerType"), managerType));
Long count2 = em.createQuery(cq).getSingleResult();
return count1 > 0 || count2 > 0;
} catch (Exception e) {
return true;
}
}
ApplianceManagerConnectorEntityMgr.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:osc-core
作者:
评论列表
文章目录