List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
License:Open Source License
public List<VirtualMachine> findVirtualMachines(final Hypervisor hypervisor) { assert hypervisor != null; assert isManaged2(hypervisor); Criteria criteria = createCriteria(sameHypervisor(hypervisor)); criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY)); List<VirtualMachine> result = getResultList(criteria); return result; }
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
License:Open Source License
public List<VirtualMachine> findVirtualMachinesNotAllocatedCompatibleHypervisor(final Hypervisor hypervisor) { Criteria criteria = createCriteria(); criteria.createAlias(VirtualMachine.VIRTUAL_MACHINE_TEMPLATE_PROPERTY, "template"); Restrictions.and(Restrictions.eq(VirtualMachine.HYPERVISOR_PROPERTY, null), Restrictions.in("template." + VirtualMachineTemplate.DISKFORMAT_TYPE_PROPERTY, Arrays.asList(hypervisor.getType().compatibleFormats))); criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY)); List<VirtualMachine> result = getResultList(criteria); return result; }
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
License:Open Source License
public List<VirtualMachine> findVirtualMachinesByEnterprise(final Enterprise enterprise) { assert enterprise != null; assert isManaged2(enterprise); Criteria criteria = createCriteria(sameEnterprise(enterprise)); criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY)); List<VirtualMachine> result = getResultList(criteria); return result; }
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
License:Open Source License
public List<VirtualMachine> findVirtualMachinesByUser(final Enterprise enterprise, final User user) { Criteria criteria = createCriteria(sameUser(user)).add(sameEnterprise(enterprise)); criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY)); List<VirtualMachine> result = getResultList(criteria); return result; }
From source file:com.abiquo.server.core.common.persistence.DefaultDAOBase.java
License:Open Source License
protected Criteria createNestedCriteria(final Order order, final String... propertyNames) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.addOrder(order); return createNestedCriteria(crit, propertyNames); }
From source file:com.abiquo.server.core.config.SystemPropertyDAO.java
License:Open Source License
public SystemProperty findByName(String name) { Criteria criteria = createCriteria(equalsName(name)); criteria.addOrder(Order.asc(SystemProperty.NAME_PROPERTY)); List<SystemProperty> result = getResultList(criteria); return result.isEmpty() ? null : result.get(0); }
From source file:com.abiquo.server.core.config.SystemPropertyDAO.java
License:Open Source License
public List<SystemProperty> findByComponent(String component) { Criteria criteria = createCriteria(equalsComponent(component)); criteria.addOrder(Order.asc(SystemProperty.NAME_PROPERTY)); return getResultList(criteria); }
From source file:com.abiquo.server.core.enterprise.EnterpriseDAO.java
License:Open Source License
public List<Enterprise> findByNameAnywhere(final String name) { assert name != null; Criteria criteria = createCriteria(nameLikeAnywhere(name)); criteria.addOrder(Order.asc(Enterprise.NAME_PROPERTY)); List<Enterprise> result = getResultList(criteria); return result; }
From source file:com.abiquo.server.core.enterprise.RoleDAO.java
License:Open Source License
private Criteria createCriteria(final Enterprise enterprise, final String filter, final String orderBy, final boolean desc, final boolean discardNullEnterprises) { Criteria criteria = createCriteria(); if (enterprise != null) { if (discardNullEnterprises) { criteria.add(sameEnterprise(enterprise)); } else {/* w w w . j av a2 s .com*/ criteria.add(sameEnterpriseOrNull(enterprise)); } } else { criteria.add(genericRole()); } if (!StringUtils.isEmpty(filter)) { criteria.add(filterBy(filter)); } if (!StringUtils.isEmpty(orderBy)) { Order order = Order.asc(orderBy); if (desc) { order = Order.desc(orderBy); } criteria.addOrder(order); criteria.addOrder(Order.asc(Role.NAME_PROPERTY)); } return criteria; }
From source file:com.abiquo.server.core.enterprise.RoleDAO.java
License:Open Source License
private Criteria createCriteriaExactly(final Enterprise enterprise, final String filter, final String orderBy, final boolean desc, final boolean discardNullEnterprises) { Criteria criteria = createCriteria(); if (enterprise != null) { if (discardNullEnterprises) { criteria.add(sameEnterprise(enterprise)); } else {/* www . jav a2 s .com*/ criteria.add(sameEnterpriseOrNull(enterprise)); } } // BUG ABICLOUDPREMIUM-3124 // else // { // criteria.add(genericRole()); // } if (!StringUtils.isEmpty(filter)) { criteria.add(filterExactlyBy(filter)); } if (!StringUtils.isEmpty(orderBy)) { Order order = Order.asc(orderBy); if (desc) { order = Order.desc(orderBy); } criteria.addOrder(order); criteria.addOrder(Order.asc(Role.NAME_PROPERTY)); } return criteria; }