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.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.infrastructure.hibernate.RemoteServiceDAOHibernate.java
License:Open Source License
@Override public List<RemoteServiceHB> getRemoteServicesByUrl(String uri) { Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query pmQuery = session.getNamedQuery(REMOTE_SERVICE_GET_REMOTE_SERVICES_BY_URL); pmQuery.setString("uri", uri); return pmQuery.list(); }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.IpPoolManagementDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//ww w . ja va2 s. c o m 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 ww. ja va 2 s . c o m*/ 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;//from w ww . j ava 2s.c o m 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 www .j a v a 2 s . 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; }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.VlanNetworkDAOHibernate.java
License:Open Source License
@Override public Long howManyUsedIPs(final Integer vlanNetworkId) throws PersistenceException { try {/*from ww w . ja va 2 s . co m*/ final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_NUMBER_IPS_USED_BY_VLAN); query.setInteger("vlan_network_id", vlanNetworkId); return (Long) query.uniqueResult(); } catch (final HibernateException e) { throw new PersistenceException(e.getMessage(), e); } }
From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.VlanNetworkDAOHibernate.java
License:Open Source License
@Override public Long howManyVDCs(final Integer vlanNetworkId) throws PersistenceException { try {/*from w w w. j a v a 2s. com*/ final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); final Query query = session.getNamedQuery(GET_NUMBER_VDCS_USED_BY_VLAN); query.setInteger("vlan_network_id", vlanNetworkId); return (Long) query.uniqueResult(); } catch (final HibernateException e) { throw new PersistenceException(e.getMessage(), e); } }