List of usage examples for org.hibernate SQLQuery setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(int position, String val)
From source file:com.globalsight.everest.workflow.WorkflowJbpmPersistenceHandler.java
License:Apache License
/** * Judges whether the task is rejected<br> * The rule for judges the task whether is rejected is as below: * <ul>/*from w w w. j a va 2s . c o m*/ * <li>If the lp reject the task, the task showed rejected by the lp</li> * <li>If the lp(s) reject the task and there is extra lp availabe for the * task, the task showed rejected for pm</li> * * <li>If the lp(s) reject the task and there is no extra lp availabe for * the task, the task showed availabe for pm</li> * </ul> * * * @param ctx * {@code JbpmContext} * @param taskInstance * {@code TaskInstance} * @param p_pm * The name of the pm * @return <code>true</code> when the task is rejected */ public static boolean isTaskRejected(JbpmContext ctx, TaskInstance taskInstance, String p_pm) { SQLQuery query = null; Session session = ctx.getSession(); query = session.createSQLQuery(SqlHolder.isTaskReject); query.setString(VARIABLE_NAME, WorkflowConstants.VARIABLE_IS_REJECTED); query.setString(CATEGORY, VARIABLE_CATEGORY_REJECT); query.setString(PM, p_pm); query.setLong(TASK_ID, taskInstance.getId()); Number num = (Number) query.uniqueResult(); /* normally, the num should not be null */ return num == null ? false : num.longValue() > 0; }
From source file:com.globalsight.everest.workflow.WorkflowJbpmPersistenceHandler.java
License:Apache License
public static List<String> getSkippedTaskInstance(long workflowId, JbpmContext p_ctx) { Session session = p_ctx.getSession(); SQLQuery query = session.createSQLQuery(SqlHolder.skippedTask); query.setString(WORKFLOW_ID, String.valueOf(workflowId)); return query.list(); }
From source file:com.globalsight.everest.workflow.WorkflowJbpmUtil.java
License:Apache License
public static List<Long> getRejectedTaskIds(List<TaskInstance> tasks, String p_userId) { JbpmContext ctx = WorkflowConfiguration.getInstance().getCurrentContext(); List<Long> allIds = new ArrayList<Long>(); if (tasks == null || tasks.size() == 0) { return allIds; }//from w w w .j a v a 2 s . co m for (TaskInstance task : tasks) { allIds.add(task.getId()); } String idsString = allIds.toString(); idsString = idsString.substring(1, idsString.length() - 1); StringBuffer sql = new StringBuffer("select vi.TASKINSTANCE_ID "); sql.append("from JBPM_GS_VARIABLE vi "); sql.append("where vi.NAME = :name and vi.VALUE = :value "); sql.append("and vi.CATEGORY = 'reject' and vi.TASKINSTANCE_ID in (:ids);"); SQLQuery query = null; Session session = ctx.getSession(); query = session.createSQLQuery(sql.toString()); query.setString("name", WorkflowConstants.VARIABLE_IS_REJECTED); query.setString("value", p_userId); query.setParameterList("ids", allIds); List<Long> ids = new ArrayList<Long>(); for (Object id : query.list()) { // id is BigInteger ids.add(Long.parseLong(id.toString())); } return ids; }
From source file:com.gp.cong.lcl.common.constant.ExportUnitQueryUtils.java
public List<ExportVoyageSearchModel> searchByUnCompleteUnit(Integer pooId, Integer fdId, String serviceType) throws Exception { StringBuilder queryStr = new StringBuilder(); queryStr.append(this.selectvoyageSearchQuery()); queryStr.append(" FROM "); queryStr.append(" lcl_ss_header lsh "); queryStr.append(" JOIN un_location pod ON lsh.destination_id=pod.id "); queryStr.append(" JOIN lcl_ss_detail lsd "); queryStr.append(" ON (lsh.id = lsd.ss_header_id "); queryStr.append(" AND lsh.status <> 'V' "); queryStr.append(" AND lsd.`id` = (SELECT ls.id FROM "); queryStr.append(" lcl_ss_detail ls "); queryStr.append(" WHERE ls.`ss_header_id` = lsh.id "); queryStr.append(" ORDER BY id DESC LIMIT 1)) "); queryStr.append(" JOIN lcl_unit_ss lus "); queryStr.append(" ON (lus.ss_header_id = lsh.id ) "); queryStr.append(//from w ww. j a v a2s. c o m " JOIN lcl_unit lu ON (lu.id=lus.unit_id) JOIN unit_type ut ON (ut.id = lu.unit_type_id) "); queryStr.append(" WHERE lsh.service_type=:serviceType and lus.status = 'E' "); if (CommonUtils.isNotEmpty(pooId)) { queryStr.append(" AND lsh.origin_id =:pooId "); } if (CommonUtils.isNotEmpty(fdId)) { queryStr.append(" AND lsh.destination_id =:fdId "); } queryStr.append(" ORDER BY pod.un_loc_code ,lsh.schedule_no ASC "); SQLQuery query = getCurrentSession().createSQLQuery(queryStr.toString()); if (CommonUtils.isNotEmpty(pooId)) { query.setInteger("pooId", pooId); } if (CommonUtils.isNotEmpty(fdId)) { query.setInteger("fdId", fdId); } query.setString("serviceType", serviceType); query.setResultTransformer(Transformers.aliasToBean(ExportVoyageSearchModel.class)); query.addScalar("ssHeaderId", StringType.INSTANCE); query.addScalar("scheduleNo", StringType.INSTANCE); query.addScalar("serviceType", StringType.INSTANCE); query.addScalar("serviceType", StringType.INSTANCE); query.addScalar("fdUnLocCode", StringType.INSTANCE); query.addScalar("fdName", StringType.INSTANCE); query.addScalar("departPierUnloc", StringType.INSTANCE); query.addScalar("departPier", StringType.INSTANCE); query.addScalar("arrivalPierUnloc", StringType.INSTANCE); query.addScalar("arrivalPier", StringType.INSTANCE); query.addScalar("loadingDeadLineDate", StringType.INSTANCE); query.addScalar("etaSailDate", StringType.INSTANCE); query.addScalar("etaPodDate", StringType.INSTANCE); query.addScalar("totaltransPod", StringType.INSTANCE); query.addScalar("totaltransFd", StringType.INSTANCE); query.addScalar("vesselName", StringType.INSTANCE); query.addScalar("ssVoyage", StringType.INSTANCE); query.addScalar("carrierName", StringType.INSTANCE); query.addScalar("carrierAcctNo", StringType.INSTANCE); query.addScalar("sealNo", StringType.INSTANCE); query.addScalar("unitNo", StringType.INSTANCE); query.addScalar("unitSize", StringType.INSTANCE); query.addScalar("numberDrs", StringType.INSTANCE); query.addScalar("loadedBy", StringType.INSTANCE); query.addScalar("doorLocation", StringType.INSTANCE); query.addScalar("dispoCode", StringType.INSTANCE); query.addScalar("dispoDesc", StringType.INSTANCE); query.addScalar("isInbond", StringType.INSTANCE); query.addScalar("dispoDesc", StringType.INSTANCE); query.addScalar("isHazmat", StringType.INSTANCE); return query.list(); }
From source file:com.ikon.dao.AuthDAO.java
License:Open Source License
/** * Delete role from database/* www .j av a 2s . c o m*/ */ public static void deleteRole(String rolId) throws DatabaseException { log.debug("deleteRole({})", rolId); String qs = "delete from ikon_USER_ROLE where UR_ROLE=:rolId"; Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); Role role = (Role) session.load(Role.class, rolId); session.delete(role); // TODO: Make Hibernate handle this relation. SQLQuery q = session.createSQLQuery(qs); q.setString("rolId", rolId); q.executeUpdate(); HibernateUtil.commit(tx); } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } log.debug("deleteRole: void"); }
From source file:com.lp.server.system.automatikjob.AutomatikjobPaternoster.java
License:Open Source License
private void speicherePaternostermenge(org.hibernate.Session session, Integer paternosterIId, String cNr, BigDecimal menge, Timestamp ts) { String sql = "UPDATE WW_ARTIKELLAGERPLAETZE SET N_LAGERSTANDPATERNOSTER = ?, T_AENDERN = ? " + "WHERE I_ID = (SELECT I_ID FROM WW_ARTIKELLAGERPLAETZE " + "WHERE LAGERPLATZ_I_ID = (SELECT I_ID FROM WW_LAGERPLATZ " + "WHERE PATERNOSTER_I_ID = ? AND ARTIKEL_I_ID = " + "(SELECT I_ID FROM WW_ARTIKEL WHERE C_NR = ?)))"; org.hibernate.SQLQuery sq = session.createSQLQuery(sql); sq.setBigDecimal(0, menge);/*from w ww . jav a 2 s . c o m*/ sq.setTimestamp(1, ts); sq.setInteger(2, paternosterIId); sq.setString(3, cNr); int anzahl = sq.executeUpdate(); if (anzahl == 0) { if (menge.doubleValue() > 0) { myLogger.info("Artikel " + cNr + " ist im Paternoster ohne Paternosterlagerplatz mit Menge " + menge.doubleValue()); } } }
From source file:com.mx.teknei.pcabordo.lib.dao.impl.SbctAlarDAO.java
@Override public SbctAlar getAlarForName(String nameAlar) { SbctAlar s_alar = null;//from w ww . j a v a 2s . co m Transaction trans = null; Session session = null; try { session = LoadConnection.getSessionFactory().openSession(); } catch (ExceptionInInitializerError eiie) { System.out.println("Error al iniciar la coneccion a BD postgres:" + eiie.getMessage()); } catch (Exception e) { System.err.println("Error en LoadConnection." + e.getMessage()); } try { trans = session.beginTransaction(); SQLQuery query = session.createSQLQuery("select * from sitm.sbct_alar s where s.des_alar=?"); query.addEntity(SbctAlar.class); query.setString(0, nameAlar); s_alar = (SbctAlar) query.uniqueResult(); } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return s_alar; //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:com.mx.teknei.pcabordo.lib.dao.impl.SfalConfDAO.java
@Override public SfalConf getAlarConfForName(String nameConfAlar) { SfalConf s_alar = null;//ww w.j av a 2 s . c o m Transaction trans = null; Session session = null; try { session = LoadConnection.getSessionFactory().openSession(); } catch (ExceptionInInitializerError eiie) { System.out.println("Error al iniciar la coneccion a BD postgres:" + eiie.getMessage()); } catch (Exception e) { System.err.println("Error en LoadConnection." + e.getMessage()); } try { trans = session.beginTransaction(); SQLQuery query = session.createSQLQuery( "SELECT * FROM sitm.sfal_conf s WHERE s.id_alar = (SELECT id_alar from sitm.sbct_alar where des_alar = ? )"); query.addEntity(SfalConf.class); query.setString(0, nameConfAlar); s_alar = (SfalConf) query.uniqueResult(); } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return s_alar; }
From source file:com.neu.web.phmis.dao.AdminDao.java
public EnterpriseBean addEnterpriseBean(EnterpriseBean enterpriseBean) { try {//www .j a va 2 s . co m session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); SQLQuery query = session.createSQLQuery( "CALL addEnterprise (:number, :name, :typeId, :countyId, :street, :suite, :city, :state, :zip, :contact, :url)"); query.setString("number", enterpriseBean.getNumber()); query.setString("name", enterpriseBean.getName()); query.setInteger("typeId", enterpriseBean.getTypeId()); query.setInteger("countyId", enterpriseBean.getCountyId()); query.setString("street", enterpriseBean.getStreet()); query.setString("suite", enterpriseBean.getSuite()); query.setString("city", enterpriseBean.getCity()); query.setString("state", enterpriseBean.getState()); query.setString("zip", enterpriseBean.getZipCode()); query.setString("contact", enterpriseBean.getContact()); query.setString("url", enterpriseBean.getUrl()); List<Integer> list = query.list(); enterpriseBean.setId(list.get(0)); session.getTransaction().commit(); } catch (HibernateException e) { session.getTransaction().rollback(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return enterpriseBean; } }
From source file:com.neu.web.phmis.dao.AdminDao.java
public UserBean addUser(UserBean userBean) { try {/*from w ww .jav a 2 s . com*/ session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); SQLQuery query = session.createSQLQuery( "CALL addUser (:number, :userName, :emailId, :roleId, :enterpriseId, :firstName, :lastName)"); query.setString("number", userBean.getNumber()); query.setString("userName", userBean.getUsername()); query.setString("emailId", userBean.getEmailId()); query.setInteger("roleId", userBean.getRoleBean().getId()); query.setInteger("enterpriseId", userBean.getEnterpriseBean().getId()); query.setString("firstName", userBean.getFirstName()); query.setString("lastName", userBean.getLastName()); List<Object[]> list = query.list(); Object[] data = list.get(0); userBean.setId(Integer.parseInt(data[0].toString())); userBean.setPassword(data[1].toString()); session.getTransaction().commit(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); return userBean; } }