Example usage for org.hibernate Criteria addOrder

List of usage examples for org.hibernate Criteria addOrder

Introduction

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

Prototype

public Criteria addOrder(Order order);

Source Link

Document

Add an Order ordering to the result set.

Usage

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findByEnterprise(final Enterprise enterprise) {
    Criteria criteria = createCriteria(sameEnterpriseOrShared(enterprise));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    return getResultList(criteria);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findByEnterpriseAndRepository(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository) {
    Criteria criteria = createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    return getResultList(criteria);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findImportedByEnterprise(final Enterprise enterprise) {
    Criteria criteria = createCriteria(importedVirtualMachineTemplate(enterprise));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    return getResultList(criteria);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findBy(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final Category category,
        final HypervisorType hypervisor) {
    Criteria criteria = createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository));

    if (category != null) {
        criteria.add(sameCategory(category));
    }/*from   w  w  w . j  a  v a  2 s  .  c  o m*/

    if (hypervisor != null) {
        criteria.add(compatibleOrConversions(hypervisor, criteria));
    }

    // TODO
    // criteria.setProjection(Projections.distinct(Projections.id()));
    // criteria.setResultTransformer(DistinctResultTransformer.INSTANCE);
    criteria.addOrder(Order.asc(VirtualMachineTemplate.NAME_PROPERTY));

    List<VirtualMachineTemplate> result = getResultList(criteria);
    return distinct(result);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findBy(final Category category) {
    Criteria criteria = createCriteria(sameCategory(category));
    criteria.addOrder(Order.asc(VirtualMachineTemplate.NAME_PROPERTY));

    List<VirtualMachineTemplate> result = getResultList(criteria);
    return result;
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findImportedBy(final Enterprise enterprise, final Category category,
        final HypervisorType hypervisor) {
    Criteria criteria = createCriteria(importedVirtualMachineTemplate(enterprise));

    if (category != null) {
        criteria.add(sameCategory(category));
    }//  ww  w .  ja v a2  s  . co m

    if (hypervisor != null) {
        criteria.add(compatibleOrConversions(hypervisor, criteria));
    }

    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    List<VirtualMachineTemplate> result = getResultList(criteria);
    return result;
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public VirtualMachineTemplate findByPath(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final String path) {
    Criteria criteria = createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository, path));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));

    return getSingleResult(criteria);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public boolean existWithSamePath(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final String path) {
    Criteria criteria = createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository, path));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    List<VirtualMachineTemplate> result = getResultList(criteria);

    return CollectionUtils.isEmpty(result) ? false : true;
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findStatefuls() {
    Criteria criteria = createCriteria();
    criteria.add(statefulVirtualMachineTemplate(StatefulInclusion.ALL, criteria));
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    return getResultList(criteria);
}

From source file:com.abiquo.server.core.appslibrary.VirtualMachineTemplateDAO.java

License:Open Source License

public List<VirtualMachineTemplate> findStatefulsByDatacenter(final Datacenter datacenter,
        final VirtualDatacenter vdc, final StatefulInclusion stateful) {
    Criteria crit = criteriaWithStatefulNavigation();
    crit.add(statefulVirtualMachineTemplate(stateful, crit));
    crit.add(sameStatefulDatacenter(datacenter));
    if (vdc != null) {
        crit.add(sameStatefulVirtualDatacenter(vdc));
    }/*from  w w  w.  ja  va  2s.com*/
    crit.addOrder(Order.asc(VirtualMachineTemplate.NAME_PROPERTY));
    return getResultList(crit);
}