List of usage examples for org.hibernate Query setCharacter
@Deprecated @SuppressWarnings("unchecked") default Query<R> setCharacter(String name, char val)
From source file:edu.ur.hibernate.ir.item.db.HbSponsorDAO.java
License:Apache License
/** * @see edu.ur.ir.item.SponsorDAO#getCollectionSponsorsByChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, edu.ur.order.OrderType) */// w w w . java 2 s . com @SuppressWarnings("unchecked") public List<Sponsor> getCollectionSponsorsByChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, final char firstChar, final OrderType orderType) { List<Sponsor> sponsors = (List<Sponsor>) hbCrudDAO.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionSponsorNameByCharOrderDesc"); } else { q = session.getNamedQuery("getCollectionSponsorNameByCharOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return sponsors; }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * @see edu.ur.ir.person.PersonNameDAO#getCollectionPersonNamesBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, char, edu.ur.order.OrderType) *//*w w w .j a va 2 s .c o m*/ @SuppressWarnings("unchecked") public List<PersonName> getCollectionPersonNamesBetweenChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, final char firstChar, final char lastChar, final OrderType orderType) { List<PersonName> personNames = (List<PersonName>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionPersonNameByCharRangeOrderDesc"); } else { q = session.getNamedQuery("getCollectionPersonNameByCharRangeOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setCharacter(4, Character.toLowerCase(lastChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return personNames; }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * @see edu.ur.ir.person.PersonNameDAO#getCollectionPersonNamesByChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, edu.ur.order.OrderType) *//*w w w. j av a2 s .c om*/ @SuppressWarnings("unchecked") public List<PersonName> getCollectionPersonNamesByChar(final int rowStart, final int maxResults, final InstitutionalCollection collection, final char firstChar, final OrderType orderType) { List<PersonName> personNames = (List<PersonName>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getCollectionPersonNameByCharOrderDesc"); } else { q = session.getNamedQuery("getCollectionPersonNameByCharOrderAsc"); } q.setLong(0, collection.getLeftValue()); q.setLong(1, collection.getRightValue()); q.setLong(2, collection.getTreeRoot().getId()); q.setCharacter(3, Character.toLowerCase(firstChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return personNames; }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * @see edu.ur.ir.person.PersonNameDAO#getPersonNamesBetweenChar(int, int, char, char, edu.ur.order.OrderType) *//*from ww w.ja va 2s .c om*/ @SuppressWarnings("unchecked") public List<PersonName> getPersonNamesBetweenChar(final int rowStart, final int maxResults, final char firstChar, final char lastChar, final OrderType orderType) { List<PersonName> personNames = (List<PersonName>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getPersonNameByCharRangeOrderDesc"); } else { q = session.getNamedQuery("getPersonNameByCharRangeOrderAsc"); } q.setCharacter(0, Character.toLowerCase(firstChar)); q.setCharacter(1, Character.toLowerCase(lastChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return personNames; }
From source file:edu.ur.hibernate.ir.person.db.HbPersonNameDAO.java
License:Apache License
/** * @see edu.ur.ir.person.PersonNameDAO#getPersonNamesByChar(int, int, char, edu.ur.order.OrderType) *//*from w w w. ja va 2 s .c o m*/ @SuppressWarnings("unchecked") public List<PersonName> getPersonNamesByChar(final int rowStart, final int maxResults, final char firstChar, final OrderType orderType) { List<PersonName> personNames = (List<PersonName>) hbCrudDAO.getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = null; if (orderType.equals(OrderType.DESCENDING_ORDER)) { q = session.getNamedQuery("getPersonNameByCharOrderDesc"); } else { q = session.getNamedQuery("getPersonNameByCharOrderAsc"); } q.setCharacter(0, Character.toLowerCase(firstChar)); q.setFirstResult(rowStart); q.setMaxResults(maxResults); q.setFetchSize(maxResults); return q.list(); } }); return personNames; }
From source file:EFF.test.Test2.java
public PlazoletaComida identificarPlazoleta(Session s, float gradosLon, float minutosLon, float segundosLon, char orientacionLon, float gradosLat, float minutosLat, float segundosLat, char orientacionLat) { Query q = s.createQuery("from PlazoletaComida where gradosLon=:gradosLon AND " + "minutosLon=:minutosLon AND segundosLon - radio <=:segundosLon AND " + "segundosLon + radio >=:segundosLon AND orientacionLon=:orienteacionLon AND " + "gradosLat=:gradosLat AND minutosLat=:minutosLat " + "AND segundosLat - radio <=:segundosLat AND segundosLat + radio >=:segundosLat " + "AND orientacionLat=:orienteacionLat"); q.setFloat("gradosLon", gradosLon); q.setFloat("minutosLon", minutosLon); q.setFloat("segundosLon", segundosLon); q.setCharacter("orienteacionLon", orientacionLon); q.setFloat("gradosLat", gradosLat); q.setFloat("minutosLat", minutosLat); q.setFloat("segundosLat", segundosLat); q.setCharacter("orienteacionLat", orientacionLat); List<PlazoletaComida> list = q.list(); return list.get(0); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Add parameters/*w w w . j a v a2 s . c om*/ * * @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
/** * /*w w w. j a v a2 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:es.sm2.openppm.core.dao.TeamMemberDAO.java
License:Open Source License
/** * Get Employees to a time sheet pending approve * @param project//from w ww .j ava 2 s. com * @param initdate * @param enddate * @return */ public List<Employee> membersTracking(Project project, Date initdate, Date enddate) { List<Employee> employees = new ArrayList<Employee>(); String queryString = "select distinct employee.idEmployee " + "from Teammember as teammember " + "join teammember.employee as employee " + "join teammember.projectactivity as projAc " + "join projAc.project as project " + "right join employee.weektimesheets as weekTs " + "join weekTs.projecttimesheets as timesheet " + "where project.idProject = :idProject " + "and (timesheet.appLevel = :minAppLevel " + "or timesheet.appLevel = :maxAppLevel ) " + "and timesheet.timeSheetDate between :initdate and :enddate "; Query query = getSession().createQuery(queryString); query.setInteger("idProject", project.getIdProject()); query.setDate("initdate", initdate); query.setDate("enddate", enddate); query.setCharacter("minAppLevel", Constants.APP1); query.setCharacter("maxAppLevel", Constants.APP2); List<Integer> idEmployees = query.list(); StringBuilder ids = new StringBuilder(); for (Integer id : idEmployees) { if (ids.toString().equals(StringPool.BLANK)) { ids.append(id.toString()); } else { ids.append(StringPool.COMMA + id.toString()); } } if (!ids.toString().equals(StringPool.BLANK)) { Query query2 = getSession().createQuery("select employee " + "from Teammember as teammember " + "join teammember.employee as employee " + "join fetch employee.contact as contact " + "join fetch employee.resourceprofiles as resourceprofiles " + "join fetch employee.employee as rm " + "where employee.idEmployee in (" + ids.toString() + ")"); employees = query2.list(); } return employees; }
From source file:org.egov.collection.service.ReceiptHeaderService.java
License:Open Source License
/** * @param statusCode Status code of receipts to be fetched. If null or ALL, then receipts with all statuses are fetched * @param userName User name of the user who has created the receipts. If null or ALL, then receipts of all users are fetched * @param counterId Counter id on which the receipts were created. If negative, then receipts from all counters are fetched * @param serviceCode Service code for which the receipts were created. If null or ALL, then receipts of all billing services * are fetched/*from w w w . j av a 2 s. c om*/ * @return List of all receipts created by given user from given counter id and having given status */ public List<ReceiptHeader> findAllByPositionAndInboxItemDetails(final List<Long> positionIds, final String groupingCriteria) { final StringBuilder query = new StringBuilder( " select distinct (receipt) from org.egov.collection.entity.ReceiptHeader receipt "); String wfAction = null; String serviceCode = null; String userName = null; String receiptDate = null; String receiptType = null; Integer counterId = null; String paymentMode = null; final String params[] = groupingCriteria.split(CollectionConstants.SEPARATOR_HYPHEN, -1); if (params.length == 7) { wfAction = params[0]; serviceCode = params[1]; userName = params[2]; counterId = Integer.valueOf(params[4]); receiptDate = params[3]; receiptType = params[5]; paymentMode = params[6]; } final boolean allCounters = counterId == null || counterId < 0; // final boolean allPositions = positionIds == null || // positionIds.equals(CollectionConstants.ALL); final boolean allServices = serviceCode == null || serviceCode.equals(CollectionConstants.ALL); final boolean allWfAction = wfAction == null || wfAction.equals(CollectionConstants.ALL); final boolean allUserName = userName == null || userName.equals(CollectionConstants.ALL); final boolean allDate = receiptDate == null || receiptDate.equals(CollectionConstants.ALL); final SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); Date rcptDate = null; try { rcptDate = formatter.parse(receiptDate); } catch (final ParseException e) { LOGGER.error("Exception while parsing ReceiptDate", e); throw new ApplicationRuntimeException(e.getMessage()); } if (paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CASH) || paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CHEQUEORDD)) query.append("join receipt.receiptInstrument as instruments "); query.append(" where 1=1 and receipt.state.value != 'END' and receipt.state.status != 2 "); // if (!allPositions) query.append(" and receipt.state.ownerPosition.id in :positionIds"); if (!allCounters) query.append(" and receipt.location.id = :counterId"); if (!allServices && receiptType.equals(CollectionConstants.SERVICE_TYPE_BILLING)) query.append(" and receipt.service.code = :serviceCode"); if (!allWfAction) query.append(" and receipt.state.nextAction = :wfAction"); if (!allUserName) query.append(" and receipt.createdBy.username = :userName"); if (!allDate) query.append(" and (cast(receipt.receiptdate as date)) = :rcptDate"); if (receiptType.equals(CollectionConstants.SERVICE_TYPE_BILLING)) query.append(" and receipt.receipttype = :receiptType"); else query.append(" and receipt.receipttype in ('A', 'C')"); if (paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CASH) || paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CHEQUEORDD)) query.append(" and instruments.instrumentType.type in (:paymentMode )"); query.append(" order by receipt.receiptdate desc"); final Query listQuery = getSession().createQuery(query.toString()); // if (!allPositions) listQuery.setParameterList("positionIds", positionIds); if (!allCounters) listQuery.setInteger("counterId", counterId); if (!allServices && receiptType.equals(CollectionConstants.SERVICE_TYPE_BILLING)) listQuery.setString("serviceCode", serviceCode); if (!allWfAction) listQuery.setString("wfAction", wfAction); if (!allUserName) listQuery.setString("userName", userName); if (!allDate) listQuery.setDate("rcptDate", rcptDate); if (receiptType.equals(CollectionConstants.SERVICE_TYPE_BILLING)) listQuery.setCharacter("receiptType", receiptType.charAt(0)); if (paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CASH)) listQuery.setString("paymentMode", paymentMode); else if (paymentMode.equals(CollectionConstants.INSTRUMENTTYPE_CHEQUEORDD)) listQuery.setParameterList("paymentMode", new ArrayList<>(Arrays.asList("cheque", "dd"))); return listQuery.list(); }