Example usage for org.hibernate Criteria createCriteria

List of usage examples for org.hibernate Criteria createCriteria

Introduction

In this page you can find the example usage for org.hibernate Criteria createCriteria.

Prototype

public Criteria createCriteria(String associationPath) throws HibernateException;

Source Link

Document

Create a new Criteria, "rooted" at the associated entity.

Usage

From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java

License:Apache License

/**
 * @see edu.ur.ir.person.PersonNameDAO#getPersonNamesCount(java.util.List, java.lang.Long)
 *//*  ww w  .  j  a va 2 s . c o m*/
public Integer getPersonNamesCount(final Long personId) {
    Integer count = (Integer) hbCrudDAO.getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria criteria = session.createCriteria(hbCrudDAO.getClazz());
            criteria.createCriteria("personNameAuthority").add(Restrictions.idEq(personId));
            return criteria.setProjection(Projections.rowCount()).uniqueResult();
        }
    });

    return count;
}

From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java

License:Apache License

/**
 * @see edu.ur.ir.person.PersonNameDAO#getPersonNames(java.util.List, int, int, java.lang.Long)
 *//*from   w  w w.ja va 2  s. com*/
@SuppressWarnings("unchecked")
public List<PersonName> getPersonNames(final int rowStart, final int rowEnd, final Long personId) {
    List<PersonName> names = (List<PersonName>) hbCrudDAO.getHibernateTemplate()
            .execute(new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Criteria criteria = session.createCriteria(hbCrudDAO.getClazz());

                    criteria.createCriteria("personNameAuthority").add(Restrictions.idEq(personId));
                    criteria.setFirstResult(rowStart);
                    criteria.setMaxResults(rowEnd - rowStart);
                    return criteria.list();
                }
            });

    return names;
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherFileDAO.java

License:Apache License

/**
 * Find the specified files for the given researcher.
 * //w  w  w  .  j a v a 2 s  . com
 * @see edu.ur.ir.researcher.ResearcherFileDAO#getFiles(java.lang.Long, java.util.List)
 */
@SuppressWarnings("unchecked")
public List<ResearcherFile> getFiles(final Long researcherId, final List<Long> fileIds) {
    List<ResearcherFile> foundFiles = new LinkedList<ResearcherFile>();
    if (fileIds.size() > 0) {
        Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession()
                .createCriteria(hbCrudDAO.getClazz());
        criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
        criteria.add(Restrictions.in("id", fileIds));
        foundFiles = criteria.list();
    }
    return foundFiles;
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherInstitutionalItemDAO.java

License:Apache License

/**
 * Get the root researcher institutional Items for given researcher
 * /*from  w  w  w .jav  a  2 s  .co m*/
 * @see edu.ur.ir.researcher.ResearcherInstitutionalItemDAO#getRootResearcherInstitutionalItems(Long)
 */
@SuppressWarnings("unchecked")
public List<ResearcherInstitutionalItem> getRootResearcherInstitutionalItems(final Long researcherId) {
    log.debug("getRootResearcherInstitutionalItems::");
    Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession().createCriteria(hbCrudDAO.getClazz());
    criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
    criteria.add(Restrictions.isNull("parentFolder"));
    return criteria.list();
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherInstitutionalItemDAO.java

License:Apache License

/**
 * Get researcher institutional Items for specified researcher and specified parent folder
 * /*from   w w  w.j  av  a2  s .c  o  m*/
 * @see edu.ur.ir.researcher.ResearcherInstitutionalItemDAO#getSubResearcherInstitutionalItems(Long, Long)
 */
@SuppressWarnings("unchecked")
public List<ResearcherInstitutionalItem> getSubResearcherInstitutionalItems(final Long researcherId,
        final Long parentCollectionId) {
    log.debug("getSubResearcherInstitutionalItems::");
    Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession().createCriteria(hbCrudDAO.getClazz());
    criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
    criteria.createCriteria("parentFolder").add(Restrictions.idEq(parentCollectionId));
    return criteria.list();
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherInstitutionalItemDAO.java

License:Apache License

/**
 * Find the specified items for the given researcher.
 * /*from ww  w.j  av a  2s  .co m*/
 * @see edu.ur.ir.researcher.ResearcherInstitutionalItemDAO#getResearcherInstitutionalItems(java.lang.Long, java.util.List)
 */
@SuppressWarnings("unchecked")
public List<ResearcherInstitutionalItem> getResearcherInstitutionalItems(final Long researcherId,
        final List<Long> itemIds) {
    List<ResearcherInstitutionalItem> foundItems = new LinkedList<ResearcherInstitutionalItem>();
    if (itemIds.size() > 0) {
        Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession()
                .createCriteria(hbCrudDAO.getClazz());
        criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
        criteria.add(Restrictions.in("id", itemIds));
        foundItems = criteria.list();
    }
    return foundItems;
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherLinkDAO.java

License:Apache License

/**
 * Get the root researcher links for given researcher
 * //w ww.  j av a2 s. c om
 * @see edu.ur.ir.researcher.ResearcherLinkDAO#getRootResearcherLinks(Long)
 */
@SuppressWarnings("unchecked")
public List<ResearcherLink> getRootResearcherLinks(final Long researcherId) {
    Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession().createCriteria(hbCrudDAO.getClazz());
    criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
    criteria.add(Restrictions.isNull("parentFolder"));
    return criteria.list();

}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherLinkDAO.java

License:Apache License

/**
 * Get researcher links for specified researcher and specified parent folder
 * /*ww w.  ja va2 s .  co  m*/
 * @see edu.ur.ir.researcher.ResearcherLinkDAO#getSubResearcherLinks(Long, Long)
 */
@SuppressWarnings("unchecked")
public List<ResearcherLink> getSubResearcherLinks(final Long researcherId, final Long parentCollectionId) {
    Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession().createCriteria(hbCrudDAO.getClazz());
    criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
    criteria.createCriteria("parentFolder").add(Restrictions.idEq(parentCollectionId));
    return criteria.list();
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherLinkDAO.java

License:Apache License

/**
 * Find the specified items for the given researcher.
 * /*from  w  w w .ja v  a2  s  . c  om*/
 * @see edu.ur.ir.researcher.ResearcherLinkDAO#getResearcherLinks(java.lang.Long, java.util.List)
 */
@SuppressWarnings("unchecked")
public List<ResearcherLink> getResearcherLinks(final Long researcherId, final List<Long> itemIds) {
    List<ResearcherLink> foundItems = new LinkedList<ResearcherLink>();
    if (itemIds.size() > 0) {
        Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession()
                .createCriteria(hbCrudDAO.getClazz());
        criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
        criteria.add(Restrictions.in("id", itemIds));
        foundItems = criteria.list();
    }
    return foundItems;
}

From source file:edu.ur.hibernate.ir.researcher.db.HbResearcherPublicationDAO.java

License:Apache License

/**
 * Get the root researcher publications for given researcher
 * //from  w w  w . ja  va2s  .  co  m
 * @see edu.ur.ir.researcher.ResearcherPublicationDAO#getRootResearcherPublications(Long)
 */
@SuppressWarnings("unchecked")
public List<ResearcherPublication> getRootResearcherPublications(final Long researcherId) {
    log.debug("getRootResearcherPublications::");
    Criteria criteria = hbCrudDAO.getSessionFactory().getCurrentSession().createCriteria(hbCrudDAO.getClazz());
    criteria.createCriteria("researcher").add(Restrictions.idEq(researcherId));
    criteria.add(Restrictions.isNull("parentFolder"));
    return criteria.list();
}