List of usage examples for org.hibernate Query setInteger
@Deprecated @SuppressWarnings("unchecked") default Query<R> setInteger(String name, int val)
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.RackDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w ww. j av a2 s . c om*/ public List<PhysicalmachineHB> getPhysicalMachines(Integer rackId, String filters) { try { final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_PHYSICAL_MACHINES_BY_RACK); query.setInteger("idRack", rackId); // query.setString("filterLike", (filters == null || filters.isEmpty()) ? "%" : "%" + // filters + "%"); return (ArrayList<PhysicalmachineHB>) query.list(); } catch (HibernateException he) { throw new PersistenceException(he.getMessage()); } }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.RemoteServiceDAOHibernate.java
License:Open Source License
@Override public List<RemoteServiceHB> getAllRemoteServices(final Integer idDataCenter) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(REMOTE_SERVICE_GET_REMOTE_SERVICES_BY_DATACENTER); pmQuery.setInteger("idDataCenter", idDataCenter); return pmQuery.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.RemoteServiceDAOHibernate.java
License:Open Source License
@Override public List<RemoteServiceHB> getRemoteServicesByType(final Integer idDataCenter, final RemoteServiceType remoteServiceType) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(REMOTE_SERVICE_GET_REMOTE_SERVICES_BY_TYPE); pmQuery.setInteger("idDataCenter", idDataCenter); pmQuery.setParameter("remoteServiceType", remoteServiceType); return pmQuery.list(); }
From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.RemoteServiceDAOHibernate.java
License:Open Source License
public String getRemoteServiceUriByType(final Integer idDatacenter, final RemoteServiceType remoteServiceType) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(REMOTE_SERVICE_GET_REMOTE_SERVICES_LOCATION_BY_TYPE); pmQuery.setInteger("idDataCenter", idDatacenter); pmQuery.setParameter("remoteServiceType", remoteServiceType); return (String) pmQuery.uniqueResult(); }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.IpPoolManagementDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w ww.ja v a 2 s. com*/ public List<IpPoolManagementHB> getPrivateNICsByVirtualMachine(final Integer virtualMachineId) throws PersistenceException { try { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(IP_POOL_GET_PRIVATE_NICS_BY_VIRTUALMACHINE); query.setInteger("vmId", virtualMachineId); return query.list(); } catch (HibernateException e) { throw new PersistenceException(e.getMessage(), e); } }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.NetworkAssigmntDAOHibernate.java
License:Open Source License
public List<NetworkAssignmentHB> findByVirtualDatacenter(final Integer idVirtualDataCenter) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(GET_BY_VDC); query.setInteger("idVirtualDataCenter", idVirtualDataCenter); return query.list(); }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.NetworkAssigmntDAOHibernate.java
License:Open Source License
public NetworkAssignmentHB findByVlan(final Integer vlanNetworkId) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(GET_BY_VLAN); query.setInteger("vlanNetworkId", vlanNetworkId); return (NetworkAssignmentHB) query.uniqueResult(); }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.NetworkDAOHibernate.java
License:Open Source License
@Override public VlanNetworkHB findVlanWithName(Integer networkId, String vlanNetworkName) throws PersistenceException { VlanNetworkHB namedVLAN;/* w w w . j a va 2s.c om*/ try { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query query = session.getNamedQuery(GET_VLAN_WITH_NAME_BY_NETWORK_ID); query.setInteger("network_id", networkId); query.setString("vlan_network_name", vlanNetworkName); namedVLAN = (VlanNetworkHB) query.uniqueResult(); } catch (HibernateException e) { throw new PersistenceException(e.getMessage(), e); } return namedVLAN; }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.VlanNetworkDAOHibernate.java
License:Open Source License
@Override public Integer getFreeVLANTag(final Integer idRack) { Integer freeVlanTag = 0;/* w w w.ja va 2 s . c om*/ final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_MAX_FREE_TAG); query.setInteger("idRack", idRack); final Integer latestVlanTagUsed = (Integer) query.uniqueResult(); if (latestVlanTagUsed != null) { freeVlanTag = latestVlanTagUsed + 1; if (freeVlanTag > AbiCloudConstants.VLAN_MAX) { return null; // "The VLAN tag limitation has been reached "; } } else { freeVlanTag = 3; } if (freeVlanTag == 2) { if (freeVlanTag == AbiCloudConstants.VLAN_MAX) { return null; // "The VLAN tag limitation has been reached "; } freeVlanTag++; } return freeVlanTag; }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.VlanNetworkDAOHibernate.java
License:Open Source License
@Override public VlanNetworkHB getDefaultVLAN(final Integer idNetwork) throws PersistenceException { VlanNetworkHB defaultVLAN;/*from w ww . j a va2s . c o m*/ try { final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_DEFAULT_VLAN_BY_NETWORK_ID); query.setInteger("network_id", idNetwork); defaultVLAN = (VlanNetworkHB) query.uniqueResult(); } catch (final HibernateException e) { throw new PersistenceException(e.getMessage(), e); } return defaultVLAN; }