List of usage examples for org.hibernate Query uniqueResult
R uniqueResult();
From source file:com.bloatit.data.DaoSoftware.java
License:Open Source License
/** * @param name is the name of the software we are looking for. * @return The software with the name <code>name</code> *///from w w w .j a va 2s . co m public static DaoSoftware getByName(final String name) { final Query query = SessionManager.getNamedQuery("software.byName").setString("name", name); return (DaoSoftware) query.uniqueResult(); }
From source file:com.bloatit.data.DaoSoftware.java
License:Open Source License
/** * @param name is the name of the software we are looking for. * @return true if the software exist. false otherwise. *///from w w w . j a v a2 s. c o m public static boolean exists(final String name) { final Query query = SessionManager.getNamedQuery("software.byName.size").setString("name", name); return ((Long) query.uniqueResult()) > 0; }
From source file:com.bloatit.data.DaoTeam.java
License:Open Source License
/** * Get a team using its name./*from w w w . ja va 2 s . c o m*/ * * @param name the name of the team we are lookong for. * @return the team named <code>name<code> or null if not found. */ public static DaoTeam getByName(final String name) { final Session session = SessionManager.getSessionFactory().getCurrentSession(); final Query q = session.getNamedQuery("team.byName"); q.setString("login", name); return (DaoTeam) q.uniqueResult(); }
From source file:com.bloatit.data.DaoTeam.java
License:Open Source License
/** * Finds if a member is in this team, and which is its status. * /*w w w.ja va2 s. co m*/ * @param member The member we want to know its status. * @return {@code null} if the member is not in this team, or a set * otherwise. <br /> * Note, the returned set can be empty if the user is only a Member */ public EnumSet<UserTeamRight> getUserTeamRight(final DaoMember member) { final Query q = SessionManager.getNamedQuery("team.getUserTeamRights"); q.setEntity("member", member); q.setEntity("team", this); final DaoTeamMembership gm = (DaoTeamMembership) q.uniqueResult(); final EnumSet<UserTeamRight> rights = EnumSet.noneOf(UserTeamRight.class); if (gm == null || gm.getRights() == null) { return rights; } for (final DaoTeamRight teamRight : gm.getRights()) { rights.add(teamRight.getUserStatus()); } return rights; }
From source file:com.bloatit.data.DaoTeam.java
License:Open Source License
public long getRecentHistoryCount(final int numberOfDays) { final Query size = SessionManager.getNamedQuery("team.getRecentHistory.size"); size.setEntity("team", this); size.setDate("date", DateUtils.nowMinusSomeDays(numberOfDays)); return (Long) size.uniqueResult(); }
From source file:com.bloatit.data.DaoTeamMembership.java
License:Open Source License
/** * Get a TeamMembership line using its composite key. (HQL request) *//* ww w . ja va 2 s.com*/ protected static DaoTeamMembership get(final DaoTeam team, final DaoMember member) { final Session session = SessionManager.getSessionFactory().getCurrentSession(); final Query q = session.getNamedQuery("teamMembership.byTeamMember"); q.setEntity("bloatitTeam", team); q.setEntity("member", member); return (DaoTeamMembership) q.uniqueResult(); }
From source file:com.book.identification.dao.CategoryDAOHibernate.java
License:Apache License
public Category retrieveCategory(String categoryName, String... parentCategoryName) { Query query; if (parentCategoryName == null) { query = getSession()/*from ww w . j av a 2 s . com*/ .createQuery("Select c From Category c Where c.category = :categoryName AND c.parent is null") .setParameter("categoryName", categoryName); } else { StringBuilder stringQuery = new StringBuilder(); stringQuery.append("Select c From Category c Where c.category = :categoryName"); for (int i = 0; i < parentCategoryName.length; i++) { stringQuery.append( " AND c." + StringUtils.repeat("parent.", i + 1) + "category = :parentCategoryName" + i); } stringQuery.append( " AND c.parent" + StringUtils.repeat(".parent", parentCategoryName.length) + " is null"); query = getSession().createQuery(stringQuery.toString()).setParameter("categoryName", categoryName); for (int i = parentCategoryName.length; i > 0; i--) { query = query.setParameter("parentCategoryName" + (parentCategoryName.length - i), StringUtils.trim(parentCategoryName[i - 1])); } } return (Category) query.uniqueResult(); }
From source file:com.br.uepb.dao.LoginDAO.java
License:Open Source License
/** * Mtodo para obter o objeto LoginDomain de acordo com a identificao de usurio e senha * @param usuario Nome de usurio para realizar o login * @param senha Senha do usurio/*from ww w . j a v a2s . c o m*/ * @return LoginDomain */ public LoginDomain obtemLogin(String usuario, String senha) { Query query = SessaoAtual().createQuery("FROM LoginDomain WHERE login = :usuario AND senha = :senha"); query.setString("usuario", usuario); query.setString("senha", senha); LoginDomain login = (LoginDomain) query.uniqueResult(); return login; }
From source file:com.br.uepb.dao.LoginDAO.java
License:Open Source License
/** * Mtodo para obter o objeto LoginDomain de acordo com a identificao de id do paciente * @param idPaciente Id do paciente/* w w w.ja va 2s .c o m*/ * @return LoginDomain */ public LoginDomain obtemLoginPorPaciente(int idPaciente) { Query query = SessaoAtual().createQuery("FROM LoginDomain WHERE paciente.id = :idPaciente"); query.setParameter("idPaciente", idPaciente); LoginDomain login = (LoginDomain) query.uniqueResult(); return login; }