Example usage for org.hibernate Query setInteger

List of usage examples for org.hibernate Query setInteger

Introduction

In this page you can find the example usage for org.hibernate Query setInteger.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setInteger(String name, int val) 

Source Link

Document

Bind a named int-valued parameter.

Usage

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 w w w  . j ava2s  . c  o  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 {//  w  w w. j ava  2 s. c  o m
        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);
    }
}

From source file:com.abiquo.abiserver.persistence.dao.networking.hibernate.VlanNetworkDAOHibernate.java

License:Open Source License

@Override
public Boolean isPrivateVLAN(final Integer vlanNetworkId) throws PersistenceException {
    try {/*w ww  .  j  a va  2s  . c o m*/
        final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
        final Query query = session.getNamedQuery(IS_PUBLIC_VLAN);
        query.setInteger("vlan_network_id", vlanNetworkId);
        return (Long) query.uniqueResult() == 0L;
    } 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

@SuppressWarnings("unchecked")
@Override//w w w. j  a v a 2s .co m
public List<VlanNetworkHB> findPrivateVLANsByDatacenter(final Integer idDatacenter)
        throws PersistenceException {
    try {
        Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
        Query query = session.getNamedQuery(GET_PRIVATE_VLANS_BY_DATACENTER);
        query.setInteger("datacenterId", idDatacenter);

        return query.list();
    } 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 IpPoolManagementHB getNextAvailableIp(final Integer vlanNetworkId, final String gateway)
        throws PersistenceException {
    try {//  www  .ja v a  2  s .c  om
        Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
        Query query = session.getNamedQuery(VLAN_GET_AVAILABLE_IP_MANAGEMENT);
        query.setInteger("vlanNetworkId", vlanNetworkId);
        query.setString("gateway", gateway);

        if (query.list().size() > 0) {
            return (IpPoolManagementHB) query.list().get(0);
        } else {
            return null;
        }
    } catch (HibernateException e) {
        throw new PersistenceException(e.getMessage(), e);
    }

}

From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.EnterpriseDAOHibernate.java

License:Open Source License

@Override
public EnterpriseHB findByVirtualAppliance(final Integer idVirtualApp) {
    final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    final Query query = session.getNamedQuery(GET_BY_VIRTAL_APP);
    query.setInteger("idVirtualApp", idVirtualApp);

    return (EnterpriseHB) query.uniqueResult();
}

From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.EnterpriseDAOHibernate.java

License:Open Source License

@Override
public DatacenterLimitHB getDatacenterLimit(final int idEnterprise, final int idDatacenter) {
    final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
    final Query query = session.getNamedQuery(GET_DATACENTER_LIMITS);
    query.setInteger("idEnterprise", idEnterprise);
    query.setInteger("idDatacenter", idDatacenter);

    return (DatacenterLimitHB) query.uniqueResult();
}

From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.EnterpriseDAOHibernate.java

License:Open Source License

@Override
public EnterpriseHB getEnterpriseFromReservedVlanID(Integer vlanId) throws PersistenceException {
    try {/*from  w  w  w  .  j  a v  a  2  s .  c o m*/
        final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
        final Query query = session.getNamedQuery(GET_ENTERPRISE_FROM_VLAN_ID);
        query.setInteger("vlan_id", vlanId);

        return (query.uniqueResult() == null) ? null : (EnterpriseHB) query.uniqueResult();

    } catch (HibernateException he) {
        throw new PersistenceException(he.getMessage());
    }
}

From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.UserDAOHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from w w w  .ja v  a 2s .  c  o  m*/
public List<UserHB> getUsersByUserPrivileges(final String privilege, final Integer enterprise) {
    List<UserHB> requestedUser = new ArrayList<UserHB>();

    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
    Query userQuery = session.getNamedQuery(GET_USERS_BY_PRIVILEGE);
    userQuery.setString("privilege", privilege);
    userQuery.setInteger("enterprise", enterprise);
    requestedUser = userQuery.list();

    return requestedUser;
}

From source file:com.abiquo.abiserver.persistence.dao.virtualappliance.hibernate.VirtualApplianceDAOHibernate.java

License:Open Source License

@Override
public Integer getVirtualDatacenterId(final Integer idVirtualApp) {
    Query query = getSession().getNamedQuery(VIRTUAL_DATACENTER_ID_BY_VIRTUAL_APP_ID);
    query.setInteger("idVirtualApp", idVirtualApp);

    return (Integer) query.uniqueResult();
}