List of usage examples for org.hibernate SQLQuery uniqueResult
R uniqueResult();
From source file:com.se.common.CommonFunctions.java
public static int getPkgFeatureId(String fetName) throws FeatureNameException { if (fetName == null) { throw new FeatureNameException("There is not feature"); } else {/*from w w w . jav a2 s. co m*/ try { SQLQuery aa = session.createSQLQuery( "SELECT fet_id FROM CM.TBL_PKG_FEATURES WHERE FET_NAME = '" + fetName + "'"); int fetId = Integer.parseInt(aa.uniqueResult().toString()); return fetId; } catch (Exception ex) { throw new FeatureNameException("Error While validating Feature Name"); } } }
From source file:com.se.common.CommonFunctions.java
public static int getPlType(int plid) throws PlException { try {//from w ww. j a v a2 s . com SQLQuery aa = session.createSQLQuery("SELECT pl_type FROM cm.xlp_se_pl WHERE pl_id = " + plid); int plType = Integer.parseInt(aa.uniqueResult().toString()); return plType; } catch (Exception ex) { throw new PlException(); } }
From source file:com.se.common.CommonFunctions.java
public static int getValId(String fetVal, String fetName, int plId, boolean updated) throws FeatureValueException { try {// w ww. j a v a 2 s . co m SQLQuery aa = session.createSQLQuery( "select cm.GET_FINAL_ID(" + plId + ", '" + fetName + "', '" + fetVal + "') from dual"); int fetValId = Integer.parseInt(aa.uniqueResult().toString()); if (fetValId == 0 && !updated) { throw new FeatureValueException("Reject, Feature Value is not Found"); } else if (fetValId == 0 && updated) { throw new ApprovedValueException(); } return fetValId; } catch (Exception ex) { throw new FeatureValueException("Reject, Feature Value is not Found"); } }
From source file:com.se.common.CommonFunctions.java
public static int getMaskValId(String fetVal, boolean updated) throws FeatureValueException { try {//from www. ja v a 2 s . c o m SQLQuery aa = session.createSQLQuery("select cm.GET_MSK_MSTR_ID('" + fetVal + "') from dual"); int fetValId = Integer.parseInt(aa.uniqueResult().toString()); if (fetValId == 0 && !updated) { throw new FeatureValueException("Reject, Feature Value is not Found"); } else if (fetValId == 0 && updated) { throw new ApprovedValueException(); } return fetValId; } catch (Exception ex) { throw new FeatureValueException("Reject, Feature Value is not Found"); } }
From source file:com.se.common.CommonFunctions.java
public static int getFamCrossValId(String fetVal, boolean updated) throws FeatureValueException { try {//from w ww.j av a 2 s .c o m SQLQuery aa = session.createSQLQuery("select cm.GET_FAM_ID_Fam('" + fetVal + "') from dual"); int fetValId = Integer.parseInt(aa.uniqueResult().toString()); if (fetValId == 0 && !updated) { throw new FeatureValueException("Reject, Feature Value is not Found"); } else if (fetValId == 0 && updated) { throw new ApprovedValueException(); } return fetValId; } catch (Exception ex) { throw new FeatureValueException("Reject, Feature Value is not Found"); } }
From source file:com.se.common.CommonFunctions.java
public static int getGenValId(String fetVal, boolean updated) throws FeatureValueException { try {/*from w w w. j a v a 2 s . c o m*/ SQLQuery aa = session.createSQLQuery("select importer.get_generic_id('" + fetVal + "') from dual"); int fetValId = Integer.parseInt(aa.uniqueResult().toString()); if (fetValId == 0 && !updated) { throw new FeatureValueException("Reject, Feature Value is not Found"); } else if (fetValId == 0 && updated) { throw new ApprovedValueException(); } return fetValId; } catch (Exception ex) { throw new FeatureValueException("Reject, Feature Value is not Found"); } }
From source file:com.se.common.CommonFunctions.java
public static int getFamilyId(String fetVal, int vendorId, boolean updated) throws FeatureValueException { try {// ww w. j a v a2 s. com SQLQuery aa = session .createSQLQuery("select CM.GET_SERIES_ID('" + fetVal + "', " + vendorId + ") from dual"); int fetValId = Integer.parseInt(aa.uniqueResult().toString()); if (fetValId == 0 && !updated) { throw new FeatureValueException("Reject, Feature Value is not Found"); } else if (fetValId == 0 && updated) { throw new ApprovedValueException(); } return fetValId; } catch (Exception ex) { throw new FeatureValueException("Reject, Feature Value is not Found"); } }
From source file:com.se.common.CommonFunctions.java
public static String getFetVal(String fetName, int plId, long comId) throws NotValidRelatedFeatureException { String query = ""; try {// www. j a v a2 s. c o m if (fetName.equalsIgnoreCase("Mask")) { query = "SELECT CM.GET_MSK_PART_BY_MSK_ID(GET_MSK_ID_BY_COM_ID(" + comId + ")) FROM DUAL"; } else if (fetName.equalsIgnoreCase("Family Cross")) { query = "SELECT CM.GET_FAM_NAME(CM.GET_FAMILY_ID(" + comId + ")) FROM DUAL"; } else if (fetName.equalsIgnoreCase("Generic")) { query = "SELECT IMPORTER.GET_GEN_BY_COM_ID(" + comId + ") FROM DUAL"; } else if (fetName.equalsIgnoreCase("family")) { query = "SELECT CM.GET_FAMILY_NAME(CM.GET_FAMILY_ID(" + comId + ")) FROM DUAL"; } else { query = "SELECT CM.GET_FET_VALUE(" + plId + ", CM.GET_FET_ID(" + plId + ", '" + fetName + "'), " + comId + ")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.se.common.CommonFunctions.java
public static String getFetVal(String fetName, String plName, long comId) throws NotValidRelatedFeatureException { String query = ""; try {// w ww .j a v a2 s . co m if (fetName.equalsIgnoreCase("Mask")) { query = "SELECT CM.GET_MSK_PART_BY_MSK_ID(GET_MSK_ID_BY_COM_ID(" + comId + ")) FROM DUAL"; } else if (fetName.equalsIgnoreCase("Family Cross")) { query = "SELECT CM.GET_FAM_NAME(CM.GET_FAMILY_ID(" + comId + ")) FROM DUAL"; } else if (fetName.equalsIgnoreCase("Generic")) { query = "SELECT IMPORTER.GET_GEN_BY_COM_ID(" + comId + ") FROM DUAL"; } else if (fetName.equalsIgnoreCase("family")) { query = "SELECT CM.GET_FAMILY_NAME(CM.GET_FAMILY_ID(" + comId + ")) FROM DUAL"; } else { query = "SELECT CM.GET_FET_VALUE(CM.GET_PL_ID('" + plName + "'), " + "CM.GET_FET_ID(CM.GET_PL_ID('" + plName + "'), '" + fetName + "'), " + comId + ")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.se.common.CommonFunctions.java
public static String getFeatureName(long fetId) throws FeatureNameException { // GET_FET_NAME try {//www . jav a 2s . c o m 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"); } }