List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.UserClassDao.java
License:Open Source License
/** * Gets the user with the specified name. * //w ww . j a va 2 s .co m * @param name name of user class * @return user class or null if not found */ public UserClass findByName(String name) { Criteria cri = this.session.createCriteria(UserClass.class); cri.add(Restrictions.eq("name", name)); return (UserClass) cri.uniqueResult(); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.UserLockDao.java
License:Open Source License
/** * Finds the user lock with is for the specified user and specified * resource permission.// w w w . j a v a 2 s. c o m * * @param user user who is locked * @param perm resource which is locked * @return user lock or null if not found */ public UserLock findLock(User user, ResourcePermission perm) { Criteria cri = this.session.createCriteria(UserLock.class); cri.add(Restrictions.eq("user", user)); cri.add(Restrictions.eq("resourcePermission", perm)); return (UserLock) cri.uniqueResult(); }
From source file:au.edu.uts.eng.remotelabs.schedserver.session.impl.RigShutdownSessonStopper.java
License:Open Source License
@Override public void eventOccurred(RigStateChangeEvent event, Rig rig, org.hibernate.Session db) { try {//ww w . j a v a 2 s. c om if (event == RigStateChangeEvent.REMOVED) { /* Rig has shutdown, so will need to terminate its assigned * session, if it has one. */ Criteria qu = db.createCriteria(Session.class); qu.add(Restrictions.eq("rig", rig)).add(Restrictions.eq("active", true)); /* Whilst the above criteria are not enforced by a underlying * schema, concecptually there should only ever the one session * the rig is assigned to. */ Session ses = (Session) qu.uniqueResult(); if (ses == null) { this.logger.debug("A session is not active for rig " + rig.getName() + " so there is no need to " + "terminate a session."); return; } this.logger.info("Session for " + ses.getUserNamespace() + ':' + ses.getUserName() + " on " + "rig " + ses.getAssignedRigName() + " is being terminated because the rig has shutdown."); /* Session exists so terminate it. */ ses.setActive(false); ses.setRemovalTime(new Date()); ses.setRemovalReason("Rig " + rig.getName() + " has shutdown."); db.beginTransaction(); db.flush(); db.getTransaction().commit(); } } catch (HibernateException ex) { db.getTransaction().rollback(); this.logger.error("Failed to commit change to terminate session of rig " + rig.getName() + ", messsage: " + ex.getMessage() + '.'); } }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public ArkRolePolicyTemplate getArkRolePolicyTemplate(Long id) { Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class); criteria.add(Restrictions.eq("id", id)); return (ArkRolePolicyTemplate) criteria.uniqueResult(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public ArkPermission getArkPermissionByName(String name) { Criteria criteria = getSession().createCriteria(ArkPermission.class); criteria.add(Restrictions.eq("name", name)); return (ArkPermission) criteria.uniqueResult(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public ArkFunction getArkFunction(Long id) { Criteria criteria = getSession().createCriteria(ArkFunction.class); criteria.add(Restrictions.eq("id", id)); return (ArkFunction) criteria.uniqueResult(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public ArkModule getArkModule(Long id) { Criteria criteria = getSession().createCriteria(ArkModule.class); criteria.add(Restrictions.eq("id", id)); return (ArkModule) criteria.uniqueResult(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public long getArkModuleCount(ArkModule arkModuleCriteria) { Criteria criteria = buildArkModuleCriteria(arkModuleCriteria); criteria.setProjection(Projections.rowCount()); Long totalCount = (Long) criteria.uniqueResult(); return totalCount; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public long getArkFunctionCount(ArkFunction arkFunctionCriteria) { Criteria criteria = buildArkFunctionCriteria(arkFunctionCriteria); criteria.setProjection(Projections.rowCount()); Long totalCount = (Long) criteria.uniqueResult(); return totalCount; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public long getArkRoleModuleFunctionVOCount(ArkRoleModuleFunctionVO arkRoleModuleFunctionVoCriteria) { Criteria criteria = buildArkRoleModuleFunctionVoCriteria(arkRoleModuleFunctionVoCriteria); criteria.setProjection(Projections.rowCount()); Long totalCount = (Long) criteria.uniqueResult(); return totalCount; }