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.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();
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public String getHypervisorIP(final int machineId) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_HYPERVISOR_IP);
    pmQuery.setInteger("idphysicalmachine", machineId);

    String hyperIp = (String) pmQuery.uniqueResult();

    return hyperIp;
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public PhysicalmachineHB findByIp(final String hypervisorIp, final Integer idDataCenter) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_FROM_IP);
    pmQuery.setString("ipPhysicalMachine", hypervisorIp);
    pmQuery.setInteger("idDataCenter", idDataCenter);

    PhysicalmachineHB pm = (PhysicalmachineHB) pmQuery.uniqueResult();

    return pm;//from  w ww .  j a va2  s  .  co m
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public List<VirtualmachineHB> getNotDeployedVirtualMachines(final Integer hostId) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_NOT_MANAGED_VIRTUAL_MACHINES);
    pmQuery.setInteger("idphysicalmachine", hostId);

    return pmQuery.list();
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public List<PhysicalmachineHB> getPhysicalMachineListByDatastore(final Integer datastoreId) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    Query pmQuery = session.getNamedQuery(PHYSICALMACHINE_GET_LIST_BY_DATASTORE);
    pmQuery.setInteger("idDatastore", datastoreId);

    return pmQuery.list();
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public List<PhysicalmachineHB> getPhysicalMachineByRack(final Integer rackId, final String filters) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();

    String namedQuery = filters == null || filters.isEmpty() ? PHYSICALMACHINE_GET_LIST_BY_RACK
            : "PHYSICALMACHINE.GET_LIST_BY_RACK_AND_ENTERPRISE";

    Query pmQuery = session.getNamedQuery(namedQuery);
    pmQuery.setInteger("idRack", rackId);
    if (filters != null && !filters.isEmpty()) {
        pmQuery.setString("filterLike", "%" + filters + "%");
    }/*ww  w.  jav  a  2s.  com*/

    return pmQuery.list();
}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.PhysicalMachineDAOHibernate.java

License:Open Source License

@Override
public void updateUsedResourcesByPhysicalMachine(final Integer idPhysicalMachine) {
    final Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
    final String update = "update physicalmachine p, "
            + "(SELECT hy.idPhysicalMachine, IFNULL(SUM(vm.ram),0) ram, IFNULL(SUM(vm.cpu),0) cpu"
            + "FROM virtualmachine vm right join hypervisor hy on vm.idHypervisor = hy.id, "
            + "physicalmachine pm "
            + "WHERE (vm.state is null or vm.state != 'NOT_DEPLOYED') AND pm.idPhysicalMachine = hy.idPhysicalMachine "
            + "AND pm.idPhysicalMachine = :idPhysicalMachine " + "group by hy.idPhysicalMachine) x "
            + "set p.ramused = x.ram, p.cpuused = x.cpu where p.idPhysicalMachine = x.idPhysicalMachine ";
    final Query pmQuery = session.createSQLQuery(update);
    pmQuery.setInteger("idPhysicalMachine", idPhysicalMachine);
    pmQuery.executeUpdate();/*from ww  w  .  j  a  v a 2  s  .  c om*/

}

From source file:com.abiquo.abiserver.persistence.dao.infrastructure.hibernate.RackDAOHibernate.java

License:Open Source License

@Override
public List<Integer> getRackIdByMinVlanCount(Integer vlan_vdc, Integer idVApp) {
    Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession();
    Query query = session.getNamedQuery(FIND_BY_MIN_VLANS);

    query.setInteger("vlan_vdc", vlan_vdc);
    query.setInteger("idVApp", idVApp);

    return (List<Integer>) query.list();
}