Search in sources :

Example 1 with Comment

use of org.jbei.ice.storage.model.Comment in project ice by JBEI.

the class CommentDAO method getCommentCount.

public int getCommentCount(Entry entry) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
        Root<Comment> from = query.from(Comment.class);
        query.select(getBuilder().countDistinct(from.get("id"))).where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).uniqueResult().intValue();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) Comment(org.jbei.ice.storage.model.Comment) HibernateException(org.hibernate.HibernateException)

Example 2 with Comment

use of org.jbei.ice.storage.model.Comment in project ice by JBEI.

the class CommentDAO method retrieveComments.

public List<Comment> retrieveComments(Entry entry) {
    try {
        CriteriaQuery<Comment> query = getBuilder().createQuery(Comment.class);
        Root<Comment> from = query.from(Comment.class);
        query.select(from).where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) Comment(org.jbei.ice.storage.model.Comment) HibernateException(org.hibernate.HibernateException)

Aggregations

HibernateException (org.hibernate.HibernateException)2 DAOException (org.jbei.ice.storage.DAOException)2 Comment (org.jbei.ice.storage.model.Comment)2