List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
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 {/*from w w w.ja va 2 s . co 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. ja v a 2 s . c o 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 {/* ww w.j ava2 s .co m*/ 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 ww w. j a v a2s. co 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.RoleDAOHibernate.java
License:Open Source License
@Override public RoleHB getRoleByName(final String name) { RoleHB requestedRol = new RoleHB(); Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query userQuery = session.getNamedQuery(GET_ROLE_BY_NAME); userQuery.setString("name", name); requestedRol = (RoleHB) userQuery.uniqueResult(); return requestedRol; }
From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.UserDAOHibernate.java
License:Open Source License
/** * @see com.abiquo.abiserver.persistence.dao.user.UserDAO#getUserByLoginAuth(java.lang.String, * com.abiquo.server.core.enterprise.User.AuthType) *///from www . ja va2 s. c o m @Override public UserHB getUserByLoginAuth(final String username, String authType) { UserHB requestedUser = new UserHB(); if (authType == null) { authType = AuthType.ABIQUO.name(); } Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query userQuery = session.getNamedQuery(GET_USER_BY_USER_NAME); userQuery.setString("username", username); userQuery.setString("authType", authType); requestedUser = (UserHB) userQuery.uniqueResult(); return requestedUser; }
From source file:com.abiquo.abiserver.persistence.dao.user.hibernate.UserDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w w w. ja v a2 s . 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.user.hibernate.UserDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w .j av a 2 s. c o m public List<UserHB> getUsersByUserRol(final String role, final Integer enterprise) { List<UserHB> requestedUser = new ArrayList<UserHB>(); Session session = HibernateDAOFactory.getSessionFactory().getCurrentSession(); Query userQuery = session.getNamedQuery(GET_USERS_BY_ROLE_DESC); // userQuery.setString("roleDescription", role); // userQuery.setInteger("enterprise", enterprise); requestedUser = userQuery.list(); return requestedUser; }