Example usage for org.hibernate.criterion Restrictions and

List of usage examples for org.hibernate.criterion Restrictions and

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions and.

Prototype

public static Conjunction and(Criterion... predicates) 

Source Link

Document

Return the conjuction of multiple expressions

Usage

From source file:models.db.acentera.impl.ProjectProvidersImpl.java

License:Open Source License

public static ProjectProviders getProviderById(Long id) {

    Session session = (Session) HibernateSessionFactory.getSession();
    Criteria criteria = session.createCriteria(ProjectProviders.class);
    return (ProjectProviders) criteria.add(Restrictions.and(Restrictions.eq("id", id))).uniqueResult();
}

From source file:org.balisunrise.daa.hibernate.HCriteria.java

License:Open Source License

private org.hibernate.criterion.Criterion makeCriterion(Criterion.Junction junction) {

    List<org.hibernate.criterion.Criterion> hcs = new LinkedList<>();
    for (Criterion criterion : junction.getCriterions()) {
        org.hibernate.criterion.Criterion hc = makeCriterion(criterion);
        if (hc != null)
            hcs.add(hc);//from w  w  w.  j  a  va  2 s  . c  o  m
    }

    if (hcs.isEmpty())
        return null;
    if (hcs.size() == 1)
        return hcs.get(0);

    org.hibernate.criterion.Criterion[] array = (org.hibernate.criterion.Criterion[]) hcs.toArray();

    if (junction.getLogicType() == Query.LogicType.OR)
        return Restrictions.or(array);
    else {
        org.hibernate.criterion.Criterion hc = Restrictions.and(array);
        if (junction.getLogicType() == Query.LogicType.NOT)
            return Restrictions.not(hc);
        return hc;
    }
}

From source file:org.dspace.authorize.dao.impl.ResourcePolicyDAOImpl.java

License:BSD License

@Override
public List<ResourcePolicy> findByDso(Context context, DSpaceObject dso) throws SQLException {
    Criteria criteria = createCriteria(context, ResourcePolicy.class);
    criteria.add(Restrictions.and(Restrictions.eq("dSpaceObject", dso)));
    return list(criteria);
}

From source file:org.dspace.content.dao.impl.BitstreamFormatDAOImpl.java

License:BSD License

/**
 * Find a bitstream format by its (unique) short description
 *
 * @param context/* w w w  .j a  v a2 s.co m*/
 *            DSpace context object
 * @param desc
 *            the short description
 *
 * @return the corresponding bitstream format, or <code>null</code> if
 *         there's no bitstream format with the given short description
 * @throws java.sql.SQLException
 */
@Override
public BitstreamFormat findByShortDescription(Context context, String desc) throws SQLException {
    Criteria criteria = createCriteria(context, BitstreamFormat.class);
    criteria.add(Restrictions.and(Restrictions.eq("shortDescription", desc)));

    return uniqueResult(criteria);
}

From source file:org.dspace.eperson.dao.impl.SubscriptionDAOImpl.java

License:BSD License

@Override
public List<Subscription> findByEPerson(Context context, EPerson eperson) throws SQLException {
    Criteria criteria = createCriteria(context, Subscription.class);
    criteria.add(Restrictions.and(Restrictions.eq("ePerson", eperson)));
    return list(criteria);

}

From source file:org.dspace.handle.dao.impl.HandleDAOImpl.java

License:BSD License

@Override
public List<Handle> getHandlesByDSpaceObject(Context context, DSpaceObject dso) throws SQLException {
    Criteria criteria = createCriteria(context, Handle.class);
    criteria.add(Restrictions.and(Restrictions.eq("dso", dso)));
    return list(criteria);
}

From source file:org.dspace.identifier.dao.impl.DOIDAOImpl.java

License:BSD License

@Override
public DOI findDOIByDSpaceObject(Context context, DSpaceObject dso) throws SQLException {
    Criteria criteria = createCriteria(context, DOI.class);
    criteria.add(Restrictions.and(Restrictions.eq("dSpaceObject", dso)));
    return singleResult(criteria);
}

From source file:org.dspace.versioning.dao.impl.VersionDAOImpl.java

License:BSD License

@Override
public List<Version> findVersionsWithItems(Context context, VersionHistory versionHistory) throws SQLException {
    Criteria criteria = createCriteria(context, Version.class);
    criteria.add(Restrictions.eq("versionHistory", versionHistory));
    criteria.add(Restrictions.and(Restrictions.isNotNull("item")));
    criteria.addOrder(Order.desc("versionNumber"));
    return list(criteria);
}

From source file:org.egov.council.service.CouncilPreambleService.java

License:Open Source License

@SuppressWarnings({ "unchecked", "deprecation" })
public List<CouncilPreamble> searchFinalizedPreamble(CouncilPreamble councilPreamble) {
    final Criteria criteria = buildSearchCriteria(councilPreamble);
    criteria.createAlias("councilPreamble.implementationStatus", "implementationStatus",
            CriteriaSpecification.LEFT_JOIN)
            .add(Restrictions.or(Restrictions.isNull("implementationStatus.code"),
                    Restrictions.ne("implementationStatus.code", IMPLEMENTATION_STATUS_FINISHED)))
            .add(Restrictions.and(Restrictions.in(STATUS_CODE, RESOLUTION_APPROVED_PREAMBLE)));
    return criteria.list();
}