List of usage examples for org.hibernate SQLQuery uniqueResult
R uniqueResult();
From source file:com.se.common.CommonFunctions.java
public static String getFeatureValueByID(String fetValId) throws FeatureValueException { // GET_FET_NAME try {//from w w w . j a va 2s .com SQLQuery aa = session.createSQLQuery("SELECT CM.GET_FETVAL(" + fetValId + ") from dual"); String fetName = aa.uniqueResult().toString(); return fetName; } catch (Exception ex) { throw new FeatureValueException(); } }
From source file:com.se.common.CommonFunctions.java
public static String getFeatureName(String fetId) throws FeatureNameException { // GET_FET_NAME try {/*from www . ja v a 2 s. c o m*/ if (fetId.equalsIgnoreCase(RelatedFeatures.MASK_FET_ID)) { return RelatedFeatures.MASK_FET_ID; } else if (fetId.equalsIgnoreCase(RelatedFeatures.FAM_FET_ID)) { return RelatedFeatures.FAM_FET_ID; } else if (fetId.equalsIgnoreCase(RelatedFeatures.FAMILY_FET_ID)) { return RelatedFeatures.FAMILY_FET_ID; } else if (fetId.equalsIgnoreCase(RelatedFeatures.GEN_FET_ID)) { return RelatedFeatures.GEN_FET_ID; } SQLQuery aa = session.createSQLQuery("SELECT CM.GET_FET_NAME(" + fetId + ") from dual"); String fetName = aa.uniqueResult().toString(); return fetName; } catch (Exception ex) { throw new FeatureNameException("Feature not found"); } }
From source file:com.se.common.CommonFunctions.java
public static String getPlName(int plId) throws PlException { try {/* w w w .j a va 2s . com*/ SQLQuery aa = session.createSQLQuery("select pl_name from cm.xlp_se_pl where pl_id = " + plId); String plName = aa.uniqueResult().toString(); return plName; } catch (Exception ex) { throw new PlException(); } }
From source file:com.se.common.CommonFunctions.java
public static String getManName(int manId) throws VendorException { if (manId == 0) { return ""; }// w w w. j av a 2 s .co m try { SQLQuery aa = session .createSQLQuery("select man_name from cm.XLP_SE_MANUFACTURER where man_id = " + manId); String manName = aa.uniqueResult().toString(); return manName; } catch (Exception ex) { throw new VendorException(); } }
From source file:com.se.common.CommonFunctions.java
public static String getFetValById(String fetName, String fetValid) throws NotValidRelatedFeatureException { String query = ""; try {/*from w w w.j a v a2s .co m*/ if (fetName.equalsIgnoreCase("Mask")) { query = "SELECT CM.GET_MSK_PART_BY_MSK_ID(" + fetValid + ") FROM DUAL"; } else if (fetName.equalsIgnoreCase("Family Cross")) { query = "SELECT CM.GET_FAM_NAME(" + fetValid + ") FROM DUAL"; } else if (fetName.equalsIgnoreCase("Generic")) { query = "SELECT IMPORTER.GET_GEN_BY_GEN_ID(" + fetValid + ") FROM DUAL"; } else if (fetName.equalsIgnoreCase("family")) { query = "SELECT CM.GET_FAMILY_NAME(" + fetValid + ") FROM DUAL"; } else { query = "SELECT CM.GET_FETVAL(" + fetValid + ")FROM DUAL"; } // System.out.println(query); SQLQuery aa = session.createSQLQuery(query); String value = aa.uniqueResult() == null ? null : aa.uniqueResult().toString(); return value; } catch (Exception ex) { ex.printStackTrace(); throw new NotValidRelatedFeatureException("Can't Get Feature Value"); } }
From source file:com.square.core.dao.implementations.CampagneDaoImplementation.java
License:Open Source License
@Override public Long rechercherSequence() { Long sequence = 0L;/*ww w . j av a2 s .c o m*/ Object obj; final SQLQuery sq = createSqlQuery("SELECT nextval('campagne_sequence')"); obj = sq.uniqueResult(); sequence = (obj == null) ? null : Long.parseLong(obj.toString()); return sequence; }
From source file:com.square.core.dao.implementations.OpportuniteDaoImplementation.java
License:Open Source License
@Override public Long rechercherSequence() { Long sequence = 0L;/*from w w w. ja va2 s. c om*/ Object obj; final SQLQuery sq = createSqlQuery("SELECT nextval('opportunite_sequence')"); obj = sq.uniqueResult(); sequence = (obj == null) ? null : Long.parseLong(obj.toString()); return sequence; }
From source file:com.sysware.customize.hd.investment.baseData.vendor.VendorDaoImpl.java
/** * ?????//from w w w . j a v a 2 s . co m * @param vo * @return */ public int GetAVenderCode(Vendor vo) { int result = 0; String sql = "select * from (select t.vendorcode" + " from t_vendor t" + " where t.sector=? order by t.vendorcode desc)" + " where rownum=1"; SQLQuery query = dao.getHibernateSession().createSQLQuery(sql); query.setParameter(0, vo.getSector()); Object obj = query.uniqueResult(); if (obj == null || obj.toString().equals("")) { //?? if (vo.getSector().equals("")) result = 781000; else if (vo.getSector().equals("")) result = 611000; else if (vo.getSector().equals("")) result = 621000; else if (vo.getSector().equals("")) result = 631000; else if (vo.getSector().equals("")) result = 641000; else if (vo.getSector().equals("")) result = 651000; else if (vo.getSector().equals("?")) result = 661000; else if (vo.getSector().equals("")) result = 671000; else if (vo.getSector().equals("")) result = 681000; else if (vo.getSector().equals("")) result = 691000; else if (vo.getSector().equals("")) result = 701000; else if (vo.getSector().equals("")) result = 711000; else if (vo.getSector().equals("")) result = 721000; else if (vo.getSector().equals("??")) result = 731000; else if (vo.getSector().equals("")) result = 741000; else if (vo.getSector().equals("")) result = 751000; else if (vo.getSector().equals("?")) result = 761000; else if (vo.getSector().equals("?")) result = 771000; } else { result = Integer.parseInt(obj.toString()) + 1; } // System.out.println("?"+result); return result; }
From source file:com.thoughtworks.go.server.persistence.MaterialRepository.java
License:Apache License
private long modificationAfter(final long id, final MaterialInstance materialInstance) { BigInteger result = (BigInteger) getHibernateTemplate().execute((HibernateCallback) session -> { String sql = "SELECT id " + " FROM modifications " + " WHERE materialId = ? " + " AND id > ?" + " ORDER BY id" + " LIMIT 1"; SQLQuery query = session.createSQLQuery(sql); query.setLong(0, materialInstance.getId()); query.setLong(1, id);//from w w w . j a v a 2 s .co m return query.uniqueResult(); }); return result == null ? id : result.longValue(); }
From source file:com.thoughtworks.go.server.persistence.MaterialRepository.java
License:Apache License
private Long findLastBuiltModificationId(final Pipeline pipeline, final MaterialInstance materialInstance) { BigInteger result = (BigInteger) getHibernateTemplate().execute((HibernateCallback) session -> { String sql = "SELECT fromRevisionId " + " FROM pipelineMaterialRevisions pmr " + " INNER JOIN pipelines p on p.id = pmr.pipelineId " + " WHERE materialId = ? " + " AND p.name = ? " + " AND pipelineId < ? " + " ORDER BY pmr.id DESC" + " LIMIT 1"; SQLQuery query = session.createSQLQuery(sql); query.setLong(0, materialInstance.getId()); query.setString(1, pipeline.getName()); query.setLong(2, pipeline.getId()); return query.uniqueResult(); });/*from w w w . j a va2 s. c o m*/ return result == null ? null : result.longValue(); }