List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.DataCenterDAOHibernate.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public List<DatacenterHB> getAllowedDatacenters(final int idEnterprise) { final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_ALLOWED_DATACENTERS); query.setInteger("idEnterprise", idEnterprise); return query.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.DataCenterDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*www. ja va2s .c o m*/ public ArrayList<RackHB> getRacks(final Integer datacenterId, final String filters) { final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_RACKS_BY_DATACENTER); query.setInteger("idDatacenter", datacenterId); query.setString("filterLike", filters == null || filters.isEmpty() ? "%" : "%" + filters + "%"); return (ArrayList<RackHB>) query.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.HyperVisorDAOHibernate.java
License:Open Source License
@Override public List<HypervisorType> getHypervisorsTypeByDataCenter(DatacenterHB datacenter) throws PersistenceException { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); try {/*w w w. j a va 2 s .c o m*/ Query query = session.getNamedQuery(GET_HYPERTECH_FROM_DATACENTER); query.setString("idDataCenter", String.valueOf(datacenter.getIdDataCenter())); return query.list(); } catch (HibernateException e) { throw new PersistenceException(e.getMessage(), e); } }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.HyperVisorDAOHibernate.java
License:Open Source License
@Override public List<Integer> getUsedPortsFromDB(Integer idHypervisor, Integer idPhysicalMachine) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(GET_VDRP); query.setInteger("idHyper", idHypervisor); query.setInteger("idPM", idPhysicalMachine); return query.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.HyperVisorDAOHibernate.java
License:Open Source License
@Override public HypervisorHB getHypervisorFromPhysicalMachine(Integer pmId) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(GET_HYPER_FROM_PHYSICALMACHINE); query.setInteger("pmId", pmId); return (HypervisorHB) query.uniqueResult(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java
License:Open Source License
@Override public List<PhysicalmachineHB> getByRackAndVirtualDatacenter(final Integer idRack, final Integer idVirtualDatacenter, final Long hdRequiredOnDatastore, final EnterpriseHB enterprise) { // "(pm.ram - pm.ramUsed) >= " + vimage.getRamRequired() + // " and (pm.cpu - pm.cpuUsed) >= " + vimage.getCpuRequired(); Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(FIRST_PASS_QUERY); pmQuery.setInteger("idVirtualDataCenter", idVirtualDatacenter); pmQuery.setInteger("idRack", idRack); pmQuery.setLong("hdRequiredOnRepository", hdRequiredOnDatastore); pmQuery.setParameter("enterprise", enterprise); return pmQuery.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java
License:Open Source License
@Override public Long getNumberOfDeployedVirtualMachines(final PhysicalmachineHB pmHB) { Long numberOfDeployedMachines; Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_NUMBER_OF_DEPLOYED_MACHINES); pmQuery.setInteger("idphysicalmachine", pmHB.getIdPhysicalMachine()); numberOfDeployedMachines = (Long) pmQuery.uniqueResult(); return numberOfDeployedMachines; }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java
License:Open Source License
@Override public Long getNumberOfDeployedVirtualMachinesOwnedByOtherEnterprise(final PhysicalmachineHB pmHB, final Integer idEnterprise) { Long numberOfDeployedMachines; Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session .getNamedQuery(PHYSICALMACHINE_GET_NUMBER_OF_DEPLOYED_MACHINES_OWNED_BY_OTHER_ENTERPRISE); pmQuery.setInteger("idphysicalmachine", pmHB.getIdPhysicalMachine()); pmQuery.setInteger("identerprise", idEnterprise); List<Long> longList = pmQuery.list(); numberOfDeployedMachines = longList.get(0); return numberOfDeployedMachines; }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java
License:Open Source License
@Override public List<VirtualmachineHB> getDeployedVirtualMachines(final Integer machineId) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_DEPLOYED_VIRTUAL_MACHINES); pmQuery.setInteger("idphysicalmachine", machineId); return pmQuery.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java
License:Open Source License
@Override public List<VirtualmachineHB> getDeployedAbiquoVirtualMachines(final Integer machineId) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_DEPLOYED_ABIQUO_VIRTUAL_MACHINES); pmQuery.setInteger("idphysicalmachine", machineId); return pmQuery.list(); }