List of usage examples for org.hibernate Query setBoolean
@Deprecated @SuppressWarnings("unchecked") default Query<R> setBoolean(String name, boolean val)
From source file:dtx.oa.rbac.dao.UserDao.java
@Override public boolean updateUser(User user) { user.setPassword(StringUtil.getMD5String(user.getPassword())); Session session = HibernateUtil.getSession(); session.beginTransaction();/*from w w w.j av a2s.c o m*/ Query query = session.createQuery( "UPDATE User user SET user.password=:pwd,user.status=:status,user.remark=:remark,user.loginTime=:login_time,user.loginIp=:login_ip WHERE user.uuid=:id"); query.setString("pwd", user.getPassword()); query.setBoolean("status", user.getStatus()); query.setString("remark", user.getRemark()); query.setString("id", user.getUuid()); query.setString("login_ip", user.getLoginIp()); query.setTimestamp("login_time", user.getLoginTime()); int result = query.executeUpdate(); session.getTransaction().commit(); return result > 0; }
From source file:edu.common.dynamicextensions.entitymanager.EntityManager.java
License:BSD License
/** * This method substitues the parameters from substitutionParameterMap into the input query. * @param substitutionParameterMap//from w w w . java 2 s . com * @throws HibernateException */ private Query substitutionParameterForQuery(Session session, String queryName, Map substitutionParameterMap) throws HibernateException { Query q = session.getNamedQuery(queryName); for (int counter = 0; counter < substitutionParameterMap.size(); counter++) { HQLPlaceHolderObject hPlaceHolderObject = (HQLPlaceHolderObject) substitutionParameterMap .get(counter + ""); String objectType = hPlaceHolderObject.getType(); if (objectType.equals("string")) { q.setString(counter, hPlaceHolderObject.getValue() + ""); } else if (objectType.equals("integer")) { q.setInteger(counter, Integer.parseInt(hPlaceHolderObject.getValue() + "")); } else if (objectType.equals("long")) { q.setLong(counter, Long.parseLong(hPlaceHolderObject.getValue() + "")); } else if (objectType.equals("boolean")) { q.setBoolean(counter, Boolean.parseBoolean(hPlaceHolderObject.getValue() + "")); } } return q; }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Add parameters//from w ww.jav a 2 s . c o m * * @param query * @param filter */ private void addParameters(Query query, ProjectSearch filter) { // Add parameter for priority if (!ValidateUtil.isNull(filter.getPriority())) { if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority()) || ProjectSearch.LESS_EQUAL.equals(filter.getPriority())) && filter.getLastPriority() != null) { query.setInteger("lastPriority", filter.getLastPriority()); } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null && filter.getFirstPriority() != null) { query.setInteger("firstPriority", filter.getFirstPriority()); query.setInteger("lastPriority", filter.getLastPriority()); } } // Add parameter for risk rating if (ValidateUtil.isNotNull(filter.getRiskRating())) { if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getRiskRating()) || ProjectSearch.LESS_EQUAL.equals(filter.getRiskRating())) && filter.getLastRiskRating() != null) { query.setInteger("lastRiskRating", filter.getLastRiskRating()); } else if (ProjectSearch.BETWEEN.equals(filter.getRiskRating()) && filter.getLastRiskRating() != null && filter.getFirstRiskRating() != null) { query.setInteger("firstRiskRating", filter.getFirstRiskRating()); query.setInteger("lastRiskRating", filter.getLastRiskRating()); } } if (filter.getIncludeDisabled() != null && !filter.getIncludeDisabled()) { query.setBoolean("disable", Boolean.TRUE); } if (filter.getSince() != null) { query.setDate("since", filter.getSince()); } if (filter.getUntil() != null) { query.setDate("until", filter.getUntil()); } if (filter.getInternalProject() != null) { query.setBoolean("internalProject", filter.getInternalProject()); } if (filter.getIsGeoSelling() != null) { query.setBoolean("isGeoSelling", filter.getIsGeoSelling()); } if (filter.getBudgetYear() != null) { query.setInteger("budgetYear", filter.getBudgetYear()); } if (ValidateUtil.isNotNull(filter.getProjectName())) { query.setString("projectName", "%" + filter.getProjectName().toUpperCase() + "%"); } Integer[] idsProject = IntegerUtil.parseStringSequence(filter.getProjectName(), StringPool.COMMA); if (SettingUtil.getBoolean(filter.getSettings(), VisibilityProjectSetting.PROJECT_COLUMN_IDPROJECT) && idsProject != null) { query.setParameterList("projectNameID", idsProject); } if (ValidateUtil.isNotNull(filter.getRag())) { query.setCharacter("rag", filter.getRag().charAt(0)); } if (filter.getCompany() != null) { query.setEntity("company", filter.getCompany()); } if (filter.getEmployeeByInvestmentManager() != null) { query.setEntity("employeeByInvestmentManager", filter.getEmployeeByInvestmentManager()); } if (filter.getStakeholder() != null) { query.setEntity("stakeholder", filter.getStakeholder()); } if (filter.getProgramManager() != null) { query.setEntity("programManager", filter.getProgramManager()); } if (filter.getIsIndirectSeller() != null) { query.setBoolean("isIndirectSeller", filter.getIsIndirectSeller()); } if (ValidateUtil.isNotNull(filter.getPerformingorgs())) { query.setParameterList("performingorgs", filter.getPerformingorgs()); } if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) { query.setParameterList("employeeBySponsors", filter.getEmployeeBySponsors()); } if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) { query.setParameterList("employeeByProjectManagers", filter.getEmployeeByProjectManagers()); } if (ValidateUtil.isNotNull(filter.getCustomers())) { query.setParameterList("customers", filter.getCustomers()); } if (ValidateUtil.isNotNull(filter.getCustomertypes())) { query.setParameterList("customertypes", filter.getCustomertypes()); } if (ValidateUtil.isNotNull(filter.getPrograms())) { query.setParameterList("programs", filter.getPrograms()); } if (ValidateUtil.isNotNull(filter.getCategories())) { query.setParameterList("categories", filter.getCategories()); } if (ValidateUtil.isNotNull(filter.getSellers())) { query.setParameterList("sellers", filter.getSellers()); } if (ValidateUtil.isNotNull(filter.getGeography())) { query.setParameterList("geography", filter.getGeography()); } if (ValidateUtil.isNotNull(filter.getFundingsources())) { query.setParameterList("fundingsources", filter.getFundingsources()); } if (ValidateUtil.isNotNull(filter.getProjects())) { query.setParameterList("projects", filter.getProjects()); } if (ValidateUtil.isNotNull(filter.getStatus())) { query.setParameterList("status", filter.getStatus()); } if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) { query.setParameterList("investmentStatus", filter.getInvestmentStatus()); } if (ValidateUtil.isNotNull(filter.getLabels())) { query.setParameterList("labels", filter.getLabels()); } if (ValidateUtil.isNotNull(filter.getTechnologies())) { query.setParameterList("technologies", filter.getTechnologies()); } if (ValidateUtil.isNotNull(filter.getStageGates())) { query.setParameterList("stagegate", filter.getStageGates()); } if (ValidateUtil.isNotNull(filter.getContractTypes())) { query.setParameterList("contractTypes", filter.getContractTypes()); } if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) { query.setParameterList("employeeByFunctionalManagers", filter.getEmployeeByFunctionalManagers()); } if (ValidateUtil.isNotNull(filter.getClassificationsLevel())) { query.setParameterList("classificationsLevel", filter.getClassificationsLevel()); } if (filter.getShowInactivated() != null && !filter.getShowInactivated()) { query.setString("hideInactivated", Constants.INVESTMENT_INACTIVATED); } }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * /*from ww w . ja v a 2 s .co m*/ * @param filter * @return */ @SuppressWarnings("unchecked") public List<ProjectWrap> findProjectsForExecutiveReport(ProjectSearch filter) { String q = "SELECT DISTINCT NEW es.sm2.openppm.core.model.wrap.ProjectWrap(" + "p, " + "(SELECT CASE WHEN SUM(ch.cost) IS NULL THEN 0d ELSE SUM(ch.cost) END FROM Chargescosts ch WHERE ch.project = p AND (ch.idChargeType = 1 OR ch.idChargeType = 2 OR ch.idChargeType = 3)) " + ") " + "FROM Projectactivity pa " + "JOIN pa.project p " + "JOIN p.program pr " + "JOIN p.performingorg po " + "LEFT JOIN p.stakeholders stk " + "LEFT JOIN pa.activitysellers actSell " + "LEFT JOIN p.projectfundingsources fs " + "LEFT JOIN p.projectlabels pl " + "JOIN pa.wbsnode w "; String where = ""; // Create filter for priority if (!ValidateUtil.isNull(filter.getPriority())) { if (ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority()) && filter.getLastPriority() != null) { where += FilterUtil.addFilterAnd(where, "p.priority >= :lastPriority "); } else if (ProjectSearch.LESS_EQUAL.equals(filter.getPriority()) && filter.getLastPriority() != null) { where += FilterUtil.addFilterAnd(where, "p.priority <= :lastPriority "); } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null && filter.getFirstPriority() != null) { where += FilterUtil.addFilterAnd(where, "(p.priority BETWEEN :firstPriority AND :lastPriority) "); } } // Filter by since and until dates if (filter.getSince() != null && filter.getUntil() != null) { where += FilterUtil.addFilterAnd(where, "((p.startDate BETWEEN :since AND :until) OR (p.finishDate BETWEEN :since AND :until) OR (p.startDate <= :since AND p.finishDate >= :until))"); } else if (filter.getSince() != null) { where += FilterUtil.addFilterAnd(where, "p.startDate >= :since "); } else if (filter.getUntil() != null) { where += FilterUtil.addFilterAnd(where, "p.finishDate <= :since "); } where += FilterUtil.addFilterAnd(filter.getInternalProject(), where, "p.internalProject = :internalProject "); where += FilterUtil.addFilterAnd(filter.getBudgetYear(), where, "p.budgetYear = :budgetYear "); where += FilterUtil.addFilterAnd(filter.getProjectName(), where, "(UPPER(p.projectName) LIKE :projectName OR UPPER(p.chartLabel) LIKE :projectName OR UPPER(p.accountingCode) LIKE :projectName) "); where += FilterUtil.addFilterAnd(filter.getRag(), where, "p.rag = :rag "); where += FilterUtil.addFilterAnd(filter.getCompany(), where, "po.company = :company "); where += FilterUtil.addFilterAnd(filter.getEmployeeByInvestmentManager(), where, "p.employeeByInvestmentManager = :employeeByInvestmentManager "); if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) { where += FilterUtil.addFilterAnd(where, "p.employeeByFunctionalManager.idEmployee IN (:employeeByFunctionalManagers) "); } where += FilterUtil.addFilterAnd(filter.getStakeholder(), where, "stk.employee = :stakeholder "); where += FilterUtil.addFilterAnd(filter.getProgramManager(), where, "pr.employee = :programManager "); if (ValidateUtil.isNotNull(filter.getPerformingorgs())) { where += FilterUtil.addFilterAnd(where, "po.idPerfOrg IN (:performingorgs) "); } if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) { where += FilterUtil.addFilterAnd(where, "p.employeeBySponsor.idEmployee IN (:employeeBySponsors) "); } if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) { where += FilterUtil.addFilterAnd(where, "p.employeeByProjectManager.idEmployee IN (:employeeByProjectManagers) "); } if (ValidateUtil.isNotNull(filter.getCustomers())) { where += FilterUtil.addFilterAnd(where, "p.customer.idCustomer IN (:customers) "); } if (ValidateUtil.isNotNull(filter.getCustomertypes())) { where += FilterUtil.addFilterAnd(where, "p.contracttype.idContractType IN (:customertypes) "); } if (ValidateUtil.isNotNull(filter.getPrograms())) { where += FilterUtil.addFilterAnd(where, "p.program.idProgram IN (:programs) "); } if (ValidateUtil.isNotNull(filter.getCategories())) { where += FilterUtil.addFilterAnd(where, "p.category.idCategory IN (:categories) "); } if (ValidateUtil.isNotNull(filter.getSellers())) { where += FilterUtil.addFilterAnd(where, "actSell.seller.idSeller IN (:sellers) "); } if (ValidateUtil.isNotNull(filter.getGeography())) { where += FilterUtil.addFilterAnd(where, "p.geography.idGeography IN (:geography) "); } if (ValidateUtil.isNotNull(filter.getFundingsources())) { where += FilterUtil.addFilterAnd(where, "fs.fundingsource.idFundingSource IN (:fundingsources) "); } if (ValidateUtil.isNotNull(filter.getProjects())) { where += FilterUtil.addFilterAnd(where, "p.idProject IN (:projects) "); } if (ValidateUtil.isNotNull(filter.getStatus())) { where += FilterUtil.addFilterAnd(where, "p.status IN (:status) "); } if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) { where += FilterUtil.addFilterAnd(where, "p.investmentStatus IN (:investmentStatus) "); } if (ValidateUtil.isNotNull(filter.getLabels())) { where += FilterUtil.addFilterAnd(where, "pl.label.idLabel IN (:labels) "); } Query query = getSession().createQuery(q + where); // Add parameter for priority if (!ValidateUtil.isNull(filter.getPriority())) { if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority()) || ProjectSearch.LESS_EQUAL.equals(filter.getPriority())) && filter.getLastPriority() != null) { query.setInteger("lastPriority", filter.getLastPriority()); } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null && filter.getFirstPriority() != null) { query.setInteger("firstPriority", filter.getFirstPriority()); query.setInteger("lastPriority", filter.getLastPriority()); } } if (filter.getSince() != null) { query.setDate("since", filter.getSince()); } if (filter.getUntil() != null) { query.setDate("until", filter.getUntil()); } if (filter.getInternalProject() != null) { query.setBoolean("internalProject", filter.getInternalProject()); } if (filter.getBudgetYear() != null) { query.setInteger("budgetYear", filter.getBudgetYear()); } if (ValidateUtil.isNotNull(filter.getProjectName())) { query.setString("projectName", "%" + filter.getProjectName().toUpperCase() + "%"); } if (ValidateUtil.isNotNull(filter.getRag())) { query.setCharacter("rag", filter.getRag().charAt(0)); } if (filter.getCompany() != null) { query.setEntity("company", filter.getCompany()); } if (filter.getEmployeeByInvestmentManager() != null) { query.setEntity("employeeByInvestmentManager", filter.getEmployeeByInvestmentManager()); } if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) { query.setParameterList("employeeByFunctionalManagers", filter.getEmployeeByFunctionalManagers()); } if (filter.getStakeholder() != null) { query.setEntity("stakeholder", filter.getStakeholder()); } if (filter.getProgramManager() != null) { query.setEntity("programManager", filter.getProgramManager()); } if (ValidateUtil.isNotNull(filter.getPerformingorgs())) { query.setParameterList("performingorgs", filter.getPerformingorgs()); } if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) { query.setParameterList("employeeBySponsors", filter.getEmployeeBySponsors()); } if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) { query.setParameterList("employeeByProjectManagers", filter.getEmployeeByProjectManagers()); } if (ValidateUtil.isNotNull(filter.getCustomers())) { query.setParameterList("customers", filter.getCustomers()); } if (ValidateUtil.isNotNull(filter.getCustomertypes())) { query.setParameterList("customertypes", filter.getCustomertypes()); } if (ValidateUtil.isNotNull(filter.getPrograms())) { query.setParameterList("programs", filter.getPrograms()); } if (ValidateUtil.isNotNull(filter.getCategories())) { query.setParameterList("categories", filter.getCategories()); } if (ValidateUtil.isNotNull(filter.getSellers())) { query.setParameterList("sellers", filter.getSellers()); } if (ValidateUtil.isNotNull(filter.getGeography())) { query.setParameterList("geography", filter.getGeography()); } if (ValidateUtil.isNotNull(filter.getFundingsources())) { query.setParameterList("fundingsources", filter.getFundingsources()); } if (ValidateUtil.isNotNull(filter.getProjects())) { query.setParameterList("projects", filter.getProjects()); } if (ValidateUtil.isNotNull(filter.getStatus())) { query.setParameterList("status", filter.getStatus()); } if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) { query.setParameterList("investmentStatus", filter.getInvestmentStatus()); } if (ValidateUtil.isNotNull(filter.getLabels())) { query.setParameterList("labels", filter.getLabels()); } return query.list(); }
From source file:fr.mael.microrss.dao.impl.CategoryDaoImpl.java
License:Open Source License
@Override public Category collapse(Category category, boolean collapsed) { StringBuffer query = new StringBuffer("update Category cat set collapsed = :value "); query.append("where cat = :category "); Query q = getSessionFactory().getCurrentSession().createQuery(query.toString()); q.setEntity("category", category); q.setBoolean("value", collapsed); q.executeUpdate();//from w w w .j a v a2 s . c om return category; }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public void read(Integer userArticleId) { StringBuffer query = new StringBuffer("update UserArticle ua "); query.append("set read = :isRead "); query.append("where ua.id = :articleId "); Query q = getSession().createQuery(query.toString()); q.setBoolean("isRead", true); q.setInteger("articleId", userArticleId); q.executeUpdate();/* ww w . j av a 2s. c o m*/ }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public void read(Integer[] userArticleIds) { StringBuffer query = new StringBuffer("update UserArticle ua "); query.append("set read = :isRead "); query.append("where ua.id in (:articleIds) "); Query q = getSession().createQuery(query.toString()); q.setBoolean("isRead", true); q.setParameterList("articleIds", userArticleIds); q.executeUpdate();//from w ww . j a v a2 s . c o m }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public void star(Integer userArticleId, boolean star) { StringBuffer query = new StringBuffer("update UserArticle ua "); query.append("set starred = :starred "); query.append("where ua.id = :articleId "); Query q = getSession().createQuery(query.toString()); q.setBoolean("starred", star); q.setInteger("articleId", userArticleId); q.executeUpdate();//from w ww. ja va 2 s . c om }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public List<UserArticle> getStarred(User user, int start, int nb) { StringBuffer query = new StringBuffer("from UserArticle ua "); query.append("left join fetch ua.userLabels "); query.append("where ua.starred = :starred "); query.append("and ua.user = :user "); Query q = getSession().createQuery(query.toString()); q.setBoolean("starred", true); q.setEntity("user", user); q.setFirstResult(start);/*from w ww . ja v a 2 s . co m*/ q.setMaxResults(nb); return (List<UserArticle>) q.list(); }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public Long unreadStarred(User user) { StringBuffer query = new StringBuffer("select count(ua) from UserArticle ua "); query.append("where ua.user = :user "); query.append("and ua.read = :read "); query.append("and ua.starred = :starred"); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setBoolean("read", false); q.setBoolean("starred", true); return (Long) q.uniqueResult(); }