CommunityDAOImpl.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:chr-krenn-fhj-ws2017-sd17-pse 作者:
@Override
public List<Community> findApprovedCommunities() {
    LOG.info("findApprovedCommunites()");
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Community> criteria = builder.createQuery(Community.class);
    Root<Community> community = criteria.from(Community.class);
    try {
        criteria.where(builder.equal(community.get("state"), new Enumeration(2)));
    } catch (DatabaseException e1) {
        LOG.error("Enumeration(2).APPROVED konnte nicht erstellt werden!");
    }
    TypedQuery<Community> query = em.createQuery(criteria);
    try {
        List <Community> coms = query.getResultList();
        for(Community c : coms) {
            initializeCom(c);
        }
        return coms;
    } catch (NoResultException e) {
        LOG.error(e.toString());
        return null;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号