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> findStatefulsByCategoryAndDatacenter(final Category category,
        final Datacenter datacenter, final VirtualDatacenter vdc, final StatefulInclusion stateful) {
    Criteria crit = criteriaWithStatefulNavigation();
    crit.add(statefulVirtualMachineTemplate(stateful, crit));
    crit.add(sameCategory(category));// w ww.  ja v a 2 s  .  c  o  m
    crit.add(sameStatefulDatacenter(datacenter));
    if (vdc != null) {
        crit.add(sameStatefulVirtualDatacenter(vdc));
    }
    crit.addOrder(Order.asc(VirtualMachineTemplate.NAME_PROPERTY));
    return getResultList(crit);
}

From source file:com.abiquo.server.core.cloud.chef.RunlistElementDAO.java

License:Open Source License

public List<RunlistElement> findByVirtualMachine(final VirtualMachine virtualmachine) {
    Criteria criteria = createCriteria(sameVirtualMachine(virtualmachine));
    criteria.addOrder(Order.asc(RunlistElement.PRIORITY_PROPERTY));
    return getResultList(criteria);
}

From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java

License:Open Source License

public List<VirtualAppliance> findByEnterprise(final Enterprise enterprise) {
    Criteria criteria = createCriteria(sameEnterprise(enterprise));
    criteria.addOrder(Order.asc(VirtualAppliance.NAME_PROPERTY));

    return criteria.list();
}

From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java

License:Open Source License

public List<VirtualAppliance> findByVirtualDatacenter(final VirtualDatacenter virtualDatacenter) {
    Criteria criteria = createCriteria(sameVirtualDatacenter(virtualDatacenter));
    criteria.addOrder(Order.asc(VirtualAppliance.NAME_PROPERTY));

    return criteria.list();
}

From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java

License:Open Source License

private Criteria createCriteria(final VirtualDatacenter virtualDatacenter, final String filter,
        final OrderByEnum orderby, final boolean asc) {
    Criteria criteria = createCriteria();

    criteria.add(sameVirtualDatacenter(virtualDatacenter));

    if (!StringUtils.isEmpty(filter)) {
        criteria.add(filterBy(filter));// ww  w .  jav a  2 s  . c  o m
    }

    if (!StringUtils.isEmpty(orderby.getColumnSQL())) {
        Order order = Order.desc(orderby.getColumnSQL());
        if (asc) {
            order = Order.asc(orderby.getColumnSQL());
        }
        criteria.addOrder(order);
    }

    return criteria;
}

From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java

License:Open Source License

private Criteria createCriteria(final Enterprise enterprise, final String filter, final OrderByEnum orderby,
        final boolean asc) {
    Criteria criteria = createCriteria();

    criteria.add(sameEnterprise(enterprise));

    if (!StringUtils.isEmpty(filter)) {
        criteria.add(filterBy(filter));/*from  www  . j  a  va  2 s .c o  m*/
    }

    if (!StringUtils.isEmpty(orderby.getColumnSQL())) {
        Order order = Order.desc(orderby.getColumnSQL());
        if (asc) {
            order = Order.asc(orderby.getColumnSQL());
        }
        criteria.addOrder(order);
    }

    return criteria;
}

From source file:com.abiquo.server.core.cloud.VirtualDatacenterDAO.java

License:Open Source License

private Collection<VirtualDatacenter> findVirtualDatacentersByCriterions(final Collection<Criterion> criterions,
        final FilterOptions filterOptions) {
    Criteria criteria = getSession().createCriteria(VirtualDatacenter.class);

    for (Criterion criterion : criterions) {
        criteria.add(criterion);/*from   ww w.  ja va 2  s  .  c o m*/
    }

    criteria.addOrder(Order.asc(VirtualDatacenter.NAME_PROPERTY));

    if (filterOptions != null) {
        Integer size = criteria.list().size();

        criteria.setFirstResult(filterOptions.getStartwith());
        criteria.setMaxResults(filterOptions.getLimit());

        PagedList<VirtualDatacenter> vdcList = new PagedList<VirtualDatacenter>(criteria.list());
        vdcList.setTotalResults(size);
        vdcList.setPageSize(filterOptions.getLimit() > size ? size : filterOptions.getLimit());
        vdcList.setCurrentElement(filterOptions.getStartwith());

        return vdcList;
    } else {
        return getResultList(criteria);
    }
}

From source file:com.abiquo.server.core.cloud.VirtualDatacenterDAO.java

License:Open Source License

private Criteria createCriteria(final Collection<Criterion> criterions, final String filter,
        final OrderByEnum orderByEnum, final boolean asc) {
    Criteria criteria = getSession().createCriteria(VirtualDatacenter.class);

    for (Criterion criterion : criterions) {
        criteria.add(criterion);//  www .java  2 s .  com
    }

    if (!StringUtils.isEmpty(filter)) {
        criteria.add(filterBy(filter));
    }

    if (!StringUtils.isEmpty(orderByEnum.getColumnSQL())) {
        Order order = Order.desc(orderByEnum.getColumnSQL());
        if (asc) {
            order = Order.asc(orderByEnum.getColumnSQL());
        }
        criteria.addOrder(order);
    }
    return criteria;
}

From source file:com.abiquo.server.core.cloud.VirtualDatacenterDAO.java

License:Open Source License

public Collection<VirtualDatacenter> findByEnterprise(final Enterprise enterprise) {
    assert enterprise != null;
    assert isManaged2(enterprise);

    Criteria criteria = createCriteria(sameEnterprise(enterprise));
    criteria.addOrder(Order.asc(VirtualDatacenter.NAME_PROPERTY));
    List<VirtualDatacenter> result = getResultList(criteria);
    return result;
}

From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java

License:Open Source License

public List<VirtualMachine> findManagedVirtualMachines(final Hypervisor hypervisor) {
    assert hypervisor != null;
    assert isManaged2(hypervisor);

    Criteria criteria = createCriteria(sameHypervisor(hypervisor), managed());
    criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
    List<VirtualMachine> result = getResultList(criteria);
    return result;
}