List of usage examples for org.hibernate Query setParameterList
Query<R> setParameterList(int position, Object[] values);
From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java
@Override @Transactional/*from ww w. j av a2 s .c o m*/ @SuppressWarnings("unchecked") public ConfigErrorInfo getHeaderForConfigErrorInfo(Integer batchId, ConfigErrorInfo configErrorInfo, List<Integer> rptFieldArray) { String sql = "select fieldLabel from configurationFormFields " + " where fieldNo in (:rptFieldArray) and configId = :configId order by field(fieldNo, :rptFieldArray)"; try { Query query = sessionFactory.getCurrentSession().createSQLQuery(sql).addScalar("fieldLabel", StandardBasicTypes.STRING); query.setParameterList("rptFieldArray", rptFieldArray); query.setParameter("configId", configErrorInfo.getConfigId()); List<String> labels = query.list(); if (rptFieldArray.get(0) != 0) { configErrorInfo.setRptFieldHeading1(labels.get(0)); } if (rptFieldArray.get(1) != 0) { configErrorInfo.setRptFieldHeading2(labels.get(1)); } if (rptFieldArray.get(2) != 0) { configErrorInfo.setRptFieldHeading3(labels.get(2)); } if (rptFieldArray.get(3) != 0) { configErrorInfo.setRptFieldHeading4(labels.get(3)); } return configErrorInfo; } catch (Exception ex) { System.err.println("getErrorConfigForBatch " + ex.getCause()); return null; } }
From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java
@Override @Transactional/*from w ww . j a v a 2 s . com*/ public void trimFieldValues(Integer batchId, boolean foroutboundProcessing, Integer transactionId, boolean trimAll) { Integer id = batchId; String tableName = "transactionTranslatedIn"; String statusTable = "transactionIn"; String strBatchCol = "batchId"; if (foroutboundProcessing) { tableName = "transactionTranslatedOut"; statusTable = "transactionTarget"; strBatchCol = "batchDLId"; } String sql = "UPDATE " + tableName + " SET F1 = trim(F1)," + " F2 = trim(F2)," + " F3 = trim(F3)," + " F4 = trim(F4)," + " F5 = trim(F5)," + "F6 = trim(F6)," + "F7 = trim(F7)," + "F8 = trim(F8)," + "F9 = trim(F9)," + "F10 = trim(F10)," + "F11 = trim(F11)," + "F12 = trim(F12)," + "F13 = trim(F13)," + "F14 = trim(F14)," + "F15 = trim(F15)," + "F16 = trim(F16)," + "F17 = trim(F17)," + "F18 = trim(F18)," + "F19 = trim(F19)," + "F20 = trim(F20)," + "F21 = trim(F21)," + "F22 = trim(F22)," + "F23 = trim(F23)," + "F24 = trim(F24)," + "F25 = trim(F25)," + "F26 = trim(F26)," + "F27 = trim(F27)," + "F28 = trim(F28)," + "F29 = trim(F29)," + "F30 = trim(F30)," + "F31 = trim(F31)," + "F32 = trim(F32)," + "F33 = trim(F33)," + "F34 = trim(F34)," + "F35 = trim(F35)," + "F36 = trim(F36)," + "F37 = trim(F37)," + "F38 = trim(F38)," + "F39 = trim(F39)," + "F40 = trim(F40)," + "F41 = trim(F41)," + "F42 = trim(F42)," + "F43 = trim(F43)," + "F44 = trim(F44)," + "F45 = trim(F45)," + "F46 = trim(F46)," + "F47 = trim(F47)," + "F48 = trim(F48)," + "F49 = trim(F49)," + "F50 = trim(F50)," + "F51 = trim(F51)," + "F52 = trim(F52)," + "F53 = trim(F53)," + "F54 = trim(F54)," + "F55 = trim(F55)," + "F56 = trim(F56)," + "F57 = trim(F57)," + "F58 = trim(F58)," + "F59 = trim(F59)," + "F60 = trim(F60)," + "F61 = trim(F61)," + "F62 = trim(F62)," + "F63 = trim(F63)," + "F64 = trim(F64)," + "F65 = trim(F65)," + "F66 = trim(F66)," + "F67 = trim(F67)," + "F68 = trim(F68)," + "F69 = trim(F69)," + "F70 = trim(F70)," + "F71 = trim(F71)," + "F72 = trim(F72)," + "F73 = trim(F73)," + "F74 = trim(F74)," + "F75 = trim(F75)," + "F76 = trim(F76)," + "F77 = trim(F77)," + "F78 = trim(F78)," + "F79 = trim(F79)," + "F80 = trim(F80)," + "F81 = trim(F81)," + "F82 = trim(F82)," + "F83 = trim(F83)," + "F84 = trim(F84)," + "F85 = trim(F85)," + "F86 = trim(F86)," + "F87 = trim(F87)," + "F88 = trim(F88)," + "F89 = trim(F89)," + "F90 = trim(F90)," + "F91 = trim(F91)," + "F92 = trim(F92)," + "F93 = trim(F93)," + "F94 = trim(F94)," + "F95 = trim(F95)," + "F96 = trim(F96)," + "F97 = trim(F97)," + "F98 = trim(F98)," + "F99 = trim(F99)," + "F100 = trim(F100)," + "F101 = trim(F101)," + "F102 = trim(F102)," + "F103 = trim(F103)," + "F104 = trim(F104)," + "F105 = trim(F105)," + "F106 = trim(F106)," + "F107 = trim(F107)," + "F108 = trim(F108)," + "F109 = trim(F109)," + "F110 = trim(F110)," + "F111 = trim(F111)," + "F112 = trim(F112)," + "F113 = trim(F113)," + "F114 = trim(F114)," + "F115 = trim(F115)," + "F116 = trim(F116)," + "F117 = trim(F117)," + "F118 = trim(F118)," + "F119 = trim(F119)," + "F120 = trim(F120)," + "F121 = trim(F121)," + "F122 = trim(F122)," + "F123 = trim(F123)," + "F124 = trim(F124)," + "F125 = trim(F125)," + "F126 = trim(F126)," + "F127 = trim(F127)," + "F128 = trim(F128)," + "F129 = trim(F129)," + "F130 = trim(F130)," + "F131 = trim(F131)," + "F132 = trim(F132)," + "F133 = trim(F133)," + "F134 = trim(F134)," + "F135 = trim(F135)," + "F136 = trim(F136)," + "F137 = trim(F137)," + "F138 = trim(F138)," + "F139 = trim(F139)," + "F140 = trim(F140)," + "F141 = trim(F141)," + "F142 = trim(F142)," + "F143 = trim(F143)," + "F144 = trim(F144)," + "F145 = trim(F145)," + "F146 = trim(F146)," + "F147 = trim(F147)," + "F148 = trim(F148)," + "F149 = trim(F149)," + "F150 = trim(F150)," + "F151 = trim(F151)," + "F152 = trim(F152)," + "F153 = trim(F153)," + "F154 = trim(F154)," + "F155 = trim(F155)," + "F156 = trim(F156)," + "F157 = trim(F157)," + "F158 = trim(F158)," + "F159 = trim(F159)," + "F160 = trim(F160)," + "F161 = trim(F161)," + "F162 = trim(F162)," + "F163 = trim(F163)," + "F164 = trim(F164)," + "F165 = trim(F165)," + "F166 = trim(F166)," + "F167 = trim(F167)," + "F168 = trim(F168)," + "F169 = trim(F169)," + "F170 = trim(F170)," + "F171 = trim(F171)," + "F172 = trim(F172)," + "F173 = trim(F173)," + "F174 = trim(F174)," + "F175 = trim(F175)," + "F176 = trim(F176)," + "F177 = trim(F177)," + "F178 = trim(F178)," + "F179 = trim(F179)," + "F180 = trim(F180)," + "F181 = trim(F181)," + "F182 = trim(F182)," + "F183 = trim(F183)," + "F184 = trim(F184)," + "F185 = trim(F185)," + "F186 = trim(F186)," + "F187 = trim(F187)," + "F188 = trim(F188)," + "F189 = trim(F189)," + "F190 = trim(F190)," + "F191 = trim(F191)," + "F192 = trim(F192)," + "F193 = trim(F193)," + "F194 = trim(F194)," + "F195 = trim(F195)," + "F196 = trim(F196)," + "F197 = trim(F197)," + "F198 = trim(F198)," + "F199 = trim(F199)," + "F200 = trim(F200)," + "F201 = trim(F201)," + "F202 = trim(F202)," + "F203 = trim(F203)," + "F204 = trim(F204)," + "F205 = trim(F205)," + "F206 = trim(F206)," + "F207 = trim(F207)," + "F208 = trim(F208)," + "F209 = trim(F209)," + "F210 = trim(F210)," + "F211 = trim(F211)," + "F212 = trim(F212)," + "F213 = trim(F213)," + "F214 = trim(F214)," + "F215 = trim(F215)," + "F216 = trim(F216)," + "F217 = trim(F217)," + "F218 = trim(F218)," + "F219 = trim(F219)," + "F220 = trim(F220)," + "F221 = trim(F221)," + "F222 = trim(F222)," + "F223 = trim(F223)," + "F224 = trim(F224)," + "F225 = trim(F225)," + "F226 = trim(F226)," + "F227 = trim(F227)," + "F228 = trim(F228)," + "F229 = trim(F229)," + "F230 = trim(F230)," + "F231 = trim(F231)," + "F232 = trim(F232)," + "F233 = trim(F233)," + "F234 = trim(F234)," + "F235 = trim(F235)," + "F236 = trim(F236)," + "F237 = trim(F237)," + "F238 = trim(F238)," + "F239 = trim(F239)," + "F240 = trim(F240)," + "F241 = trim(F241)," + "F242 = trim(F242)," + "F243 = trim(F243)," + "F244 = trim(F244)," + "F245 = trim(F245)," + "F246 = trim(F246)," + "F247 = trim(F247)," + "F248 = trim(F248)," + "F249 = trim(F249)," + "F250 = trim(F250)," + "F251 = trim(F251)," + "F252 = trim(F252)," + "F253 = trim(F253)," + "F254 = trim(F254)," + "F255 = trim(F255)," + "F256= trim(F256)," + "F257= trim(F257)," + "F258= trim(F258)," + "F259= trim(F259)," + "F260= trim(F260)," + "F261= trim(F261)," + "F262= trim(F262)," + "F263= trim(F263)," + "F264= trim(F264)," + "F265= trim(F265)," + "F266= trim(F266)," + "F267= trim(F267)," + "F268= trim(F268)," + "F269= trim(F269)," + "F270= trim(F270)," + "F271= trim(F271)," + "F272= trim(F272)," + "F273= trim(F273)," + "F274= trim(F274)," + "F275= trim(F275)," + "F276= trim(F276)," + "F277= trim(F277)," + "F278= trim(F278)," + "F279= trim(F279)," + "F280= trim(F280)," + "F281= trim(F281)," + "F282= trim(F282)," + "F283= trim(F283)," + "F284= trim(F284)," + "F285= trim(F285)," + "F286= trim(F286)," + "F287= trim(F287)," + "F288= trim(F288)," + "F289= trim(F289)," + "F290= trim(F290)," + "F291= trim(F291)," + "F292= trim(F292)," + "F293= trim(F293)," + "F294= trim(F294)," + "F295= trim(F295)," + "F296= trim(F296)," + "F297= trim(F297)," + "F298= trim(F298)," + "F299= trim(F299)," + "F300= trim(F300)," + "F301= trim(F301)," + "F302= trim(F302)," + "F303= trim(F303)," + "F304= trim(F304)," + "F305= trim(F305)," + "F306= trim(F306)," + "F307= trim(F307)," + "F308= trim(F308)," + "F309= trim(F309)," + "F310= trim(F310)," + "F311= trim(F311)," + "F312= trim(F312)," + "F313= trim(F313)," + "F314= trim(F314)," + "F315= trim(F315)," + "F316= trim(F316)," + "F317= trim(F317)," + "F318= trim(F318)," + "F319= trim(F319)," + "F320= trim(F320)," + "F321= trim(F321)," + "F322= trim(F322)," + "F323= trim(F323)," + "F324= trim(F324)," + "F325= trim(F325)," + "F326= trim(F326)," + "F327= trim(F327)," + "F328= trim(F328)," + "F329= trim(F329)," + "F330= trim(F330)," + "F331= trim(F331)," + "F332= trim(F332)," + "F333= trim(F333)," + "F334= trim(F334)," + "F335= trim(F335)," + "F336= trim(F336)," + "F337= trim(F337)," + "F338= trim(F338)," + "F339= trim(F339)," + "F340= trim(F340)," + "F341= trim(F341)," + "F342= trim(F342)," + "F343= trim(F343)," + "F344= trim(F344)," + "F345= trim(F345)," + "F346= trim(F346)," + "F347= trim(F347)," + "F348= trim(F348)," + "F349= trim(F349)," + "F350= trim(F350)," + "F351= trim(F351)," + "F352= trim(F352)," + "F353= trim(F353)," + "F354= trim(F354)," + "F355= trim(F355)," + "F356= trim(F356)," + "F357= trim(F357)," + "F358= trim(F358)," + "F359= trim(F359)," + "F360= trim(F360)," + "F361= trim(F361)," + "F362= trim(F362)," + "F363= trim(F363)," + "F364= trim(F364)," + "F365= trim(F365)," + "F366= trim(F366)," + "F367= trim(F367)," + "F368= trim(F368)," + "F369= trim(F369)," + "F370= trim(F370)," + "F371= trim(F371)," + "F372= trim(F372)," + "F373= trim(F373)," + "F374= trim(F374)," + "F375= trim(F375)," + "F376= trim(F376)," + "F377= trim(F377)," + "F378= trim(F378)," + "F379= trim(F379)," + "F380= trim(F380)," + "F381= trim(F381)," + "F382= trim(F382)," + "F383= trim(F383)," + "F384= trim(F384)," + "F385= trim(F385)," + "F386= trim(F386)," + "F387= trim(F387)," + "F388= trim(F388)," + "F389= trim(F389)," + "F390= trim(F390)," + "F391= trim(F391)," + "F392= trim(F392)," + "F393= trim(F393)," + "F394= trim(F394)," + "F395= trim(F395)," + "F396= trim(F396)," + "F397= trim(F397)," + "F398= trim(F398)," + "F399= trim(F399)," + "F400= trim(F400)," + "F401= trim(F401)," + "F402= trim(F402)," + "F403= trim(F403)," + "F404= trim(F404)," + "F405= trim(F405)," + "F406= trim(F406)," + "F407= trim(F407)," + "F408= trim(F408)," + "F409= trim(F409)," + "F410= trim(F410)," + "F411= trim(F411)," + "F412= trim(F412)," + "F413= trim(F413)," + "F414= trim(F414)," + "F415= trim(F415)," + "F416= trim(F416)," + "F417= trim(F417)," + "F418= trim(F418)," + "F419= trim(F419)," + "F420= trim(F420)," + "F421= trim(F421)," + "F422= trim(F422)," + "F423= trim(F423)," + "F424= trim(F424)," + "F425= trim(F425)," + "F426= trim(F426)," + "F427= trim(F427)," + "F428= trim(F428)," + "F429= trim(F429)," + "F430= trim(F430)," + "F431= trim(F431)," + "F432= trim(F432)," + "F433= trim(F433)," + "F434= trim(F434)," + "F435= trim(F435)," + "F436= trim(F436)," + "F437= trim(F437)," + "F438= trim(F438)," + "F439= trim(F439)," + "F440= trim(F440)," + "F441= trim(F441)," + "F442= trim(F442)," + "F443= trim(F443)," + "F444= trim(F444)," + "F445= trim(F445)," + "F446= trim(F446)," + "F447= trim(F447)," + "F448= trim(F448)," + "F449= trim(F449)," + "F450= trim(F450)," + "F451= trim(F451)," + "F452= trim(F452)," + "F453= trim(F453)," + "F454= trim(F454)," + "F455= trim(F455)," + "F456= trim(F456)," + "F457= trim(F457)," + "F458= trim(F458)," + "F459= trim(F459)," + "F460= trim(F460)," + "F461= trim(F461)," + "F462= trim(F462)," + "F463= trim(F463)," + "F464= trim(F464)," + "F465= trim(F465)," + "F466= trim(F466)," + "F467= trim(F467)," + "F468= trim(F468)," + "F469= trim(F469)," + "F470= trim(F470)," + "F471= trim(F471)," + "F472= trim(F472)," + "F473= trim(F473)," + "F474= trim(F474)," + "F475= trim(F475)," + "F476= trim(F476)," + "F477= trim(F477)," + "F478= trim(F478)," + "F479= trim(F479)," + "F480= trim(F480)," + "F481= trim(F481)," + "F482= trim(F482)," + "F483= trim(F483)," + "F484= trim(F484)," + "F485= trim(F485)," + "F486= trim(F486)," + "F487= trim(F487)," + "F488= trim(F488)," + "F489= trim(F489)," + "F490= trim(F490)," + "F491= trim(F491)," + "F492= trim(F492)," + "F493= trim(F493)," + "F494= trim(F494)," + "F495= trim(F495)," + "F496= trim(F496)," + "F497= trim(F497)," + "F498= trim(F498)," + "F499= trim(F499)," + "F500= trim(F500)"; if (transactionId == 0) { sql = sql + " where " + tableName + "." + statusTable + "Id in (select id from " + statusTable + " where " + strBatchCol + " = :id "; if (!trimAll) { sql = sql + " and statusId not in ( :transRELId )"; } sql = sql + ")"; } else { sql = sql + " where " + tableName + "." + statusTable + "Id = :id "; id = transactionId; trimAll = true; } Query updateData = sessionFactory.getCurrentSession().createSQLQuery(sql); updateData.setParameter("id", id); if (!trimAll) { updateData.setParameterList("transRELId", transRELId); } try { updateData.executeUpdate(); } catch (Exception ex) { System.err.println("resetTransactionTranslatedIn " + ex.getCause()); } }
From source file:com.utest.dao.TypelessHibernateDAOImpl.java
License:Apache License
/** * Apply the given name parameter to the given Query object. This method is * copied from HibernateTemplate/* w w w .j ava2 s.c o m*/ * * @param queryObject * the Query object * @param paramName * the name of the parameter * @param value * the value of the parameter */ @SuppressWarnings("unchecked") private void applyNamedParameterToQuery(final Query queryObject, final String paramName, final Object value) { if (value instanceof Collection) { queryObject.setParameterList(paramName, (Collection) value); } else if (value instanceof Object[]) { queryObject.setParameterList(paramName, (Object[]) value); } else { queryObject.setParameter(paramName, value); } }
From source file:com.utest.dao.TypelessHibernateDAOImpl.java
License:Apache License
/** * Apply the given name parameter to the given Query object. This method is * copied from HibernateTemplate//from ww w .jav a 2s.c o m * * @param queryObject * the Query object * @param paramName * the name of the parameter * @param value * the value of the parameter * @param type * the type of the parameter */ @SuppressWarnings("unchecked") private void applyNamedParameterToQuery(final Query queryObject, final String paramName, final Object value, final Type type) { if (value instanceof Collection) { queryObject.setParameterList(paramName, (Collection) value); } else if (value instanceof Object[]) { queryObject.setParameterList(paramName, (Object[]) value); } else { queryObject.setParameter(paramName, value, type); } }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * luu danh sach chi tieu chinh// w w w . ja v a 2 s. c o m */ private void saveMainlytarget(List<MainlyTarget> lstItems, Long fileId) { List<Long> lstIdOfMainlyTargets = new ArrayList(); if (lstItems != null && !lstItems.isEmpty()) { Long previousVersionId = getLastVersionIdOfFile(fileId); List lstMainlyTarget = null; if (previousVersionId != null) { lstMainlyTarget = getMainlyTargetOfFile(previousVersionId); } for (MainlyTarget item : lstItems) { if (item == null) { continue; } item.setFileId(fileId);// if (checkMainlyTargetIsModify(item, lstMainlyTarget)) { item.setIsTemp(1l); } else { item.setIsTemp(0l); } if (item.getMainlyTargetId() != null) { getSession().merge(item); } else { getSession().save(item); } Long id = item.getMainlyTargetId(); lstIdOfMainlyTargets.add(id); } } String hql = "delete from MainlyTarget m where m.fileId = :fileId "; if (!lstIdOfMainlyTargets.isEmpty()) { hql += " and m.mainlyTargetId not in (:lstIdOfMainlyTargets)"; } Query query = getSession().createQuery(hql); query.setParameter("fileId", fileId); if (!lstIdOfMainlyTargets.isEmpty()) { query.setParameterList("lstIdOfMainlyTargets", lstIdOfMainlyTargets); } query.executeUpdate(); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * luu danh sach chi tieu san pham/*from w ww . ja va2 s .c o m*/ */ private void saveProductTarget(List<ProductTarget> lstItems, Long fileId, Long type, Long status) { List<Long> lstUpdateItems = new ArrayList(); Long previousVersionId = getLastVersionIdOfFile(fileId); List lstProductTarget = null; if (previousVersionId != null) { lstProductTarget = getProductTargetOfFile(previousVersionId); } if (lstItems != null && !lstItems.isEmpty()) { for (ProductTarget item : lstItems) { if (item == null) { continue; } item.setFileId(fileId); if (checkProductTargetIsModify(item, lstProductTarget, status)) { item.setIsTemp(1l); } else { item.setIsTemp(0l); } if (item.getProductTargetId() != null) { getSession().merge(item); } else { getSession().save(item); } Long id = item.getProductTargetId(); lstUpdateItems.add(id); } } String hql = "delete from ProductTarget m where m.fileId = :fileId and m.targetType=:type"; if (!lstUpdateItems.isEmpty()) { hql += " and m.productTargetId not in (:lstUpdateItems)"; } Query query = getSession().createQuery(hql); query.setParameter("type", type); query.setParameter("fileId", fileId); if (!lstUpdateItems.isEmpty()) { query.setParameterList("lstUpdateItems", lstUpdateItems); } query.executeUpdate(); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * Luu cac file attach//from w ww. j av a2s . c o m */ private void saveAttachs(List<VoAttachs> lstItems, Long fileId, String lstAttachLabel) { List<Long> lstIdOfAttachs = new ArrayList();//danh sach id cua lst Attach if (lstItems != null && !lstItems.isEmpty()) { boolean isEdit = false;//la sua if (fileId != null && fileId > 0L) {//neu ton tai id la sua isEdit = true; } if (lstAttachLabel != null) {//danh sach nhan lstAttachLabel = ";" + lstAttachLabel; } else { lstAttachLabel = ""; } Long previousVersionId = getLastVersionIdOfFile(fileId);//tim version moi nhat cua attach List lstPreviousVersionAtt = null;//danh sach version if (previousVersionId != null) { lstPreviousVersionAtt = getAttachsOfFile(previousVersionId); } for (VoAttachs item : lstItems) { Long attachId = item.getAttachId(); if (attachId == null) { continue; } lstIdOfAttachs.add(attachId); } List<VoAttachs> lstOldAttachs = null; if (!lstIdOfAttachs.isEmpty()) { String hql = "select v from VoAttachs v where v.attachId in (:lstIdOfAttachs)"; Query query = getSession().createQuery(hql); query.setParameterList("lstIdOfAttachs", lstIdOfAttachs); lstOldAttachs = query.list(); } for (int i = 0; i < lstItems.size(); i++) { VoAttachs item = lstItems.get(i); Long attachId = item.getAttachId(); if (lstAttachLabel.indexOf(";" + i + ";") >= 0) { item.setObjectType(com.viettel.common.util.Constants.OBJECT_TYPE.FILES_LABEL); } else { item.setObjectType(com.viettel.common.util.Constants.OBJECT_TYPE.FILES); } item.setObjectId(fileId); if (attachId == null) { item.setIsActive(1l); getSession().save(item); } else { for (VoAttachs oldItem : lstOldAttachs) { if (oldItem.getAttachId().equals(attachId)) { oldItem.setCategoryName(item.getCategoryName()); oldItem.setAttachDes(item.getAttachDes()); oldItem.setObjectType(item.getObjectType()); item = oldItem; break; } } if (checkAttachIsModify(item, lstPreviousVersionAtt)) { item.setIsTemp(1l); } else { item.setIsTemp(0l); } item.setObjectId(fileId); if (item.getAttachId() != null && fileId != null && fileId > 0L) { getSession().merge(item); } else if (!isEdit) { getSession().save(item); } } Long id = item.getAttachId(); lstIdOfAttachs.add(id); } } if (fileId != null && fileId > 0L) {//sua ho so hay khong sua ho so FilesDAOHE fdaohe = new FilesDAOHE(); Files fbo = fdaohe.findById(fileId); if (fbo == null || !fbo.getStatus().equals(Constants.FILE_STATUS.EVALUATED_TO_ADD)) { //la sua moi thuc hien xoa khong thi k xoa gi ca String hql = "delete from VoAttachs m" + " where m.objectId = :filesId" + " and (m.objectType= :objectType1 or m.objectType= :objectType2) "; if (!lstIdOfAttachs.isEmpty()) { hql += " and m.attachId not in (:lstIdOfAttachs)"; } Query query = getSession().createQuery(hql); query.setParameter("filesId", fileId); query.setParameter("objectType1", com.viettel.common.util.Constants.OBJECT_TYPE.FILES); query.setParameter("objectType2", com.viettel.common.util.Constants.OBJECT_TYPE.FILES_LABEL); if (!lstIdOfAttachs.isEmpty()) { query.setParameterList("lstIdOfAttachs", lstIdOfAttachs); } query.executeUpdate(); } else { //la sua moi thuc hien xoa khong thi k xoa gi ca String hql = "update VoAttachs m set m.isActive = -1" + " where m.objectId = :filesId" + " and (m.objectType= :objectType1 or m.objectType= :objectType2) "; if (!lstIdOfAttachs.isEmpty()) { hql += " and m.attachId not in (:lstIdOfAttachs)"; } Query query = getSession().createQuery(hql); query.setParameter("filesId", fileId); query.setParameter("objectType1", com.viettel.common.util.Constants.OBJECT_TYPE.FILES); query.setParameter("objectType2", com.viettel.common.util.Constants.OBJECT_TYPE.FILES_LABEL); if (!lstIdOfAttachs.isEmpty()) { query.setParameterList("lstIdOfAttachs", lstIdOfAttachs); } query.executeUpdate(); } } }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
private void saveQualityPlan(List<QualityControlPlan> lstItems, Long fileId) { List<Long> lstIdOfQualitys = new ArrayList(); if (lstItems != null && !lstItems.isEmpty()) { for (QualityControlPlan item : lstItems) { if (item.getQualityControlPlanId() != null) {//kiem tra ban tren form khac trong db k neu khach oanh dau co sua doi va luu ban goc // QualityControlPlan itemOnDB = (QualityControlPlan) findById(QualityControlPlan.class, "qualityControlPlanId", item.getQualityControlPlanId()); QualityControlPlanDAOHE qualityControlPlanDAOHE = new QualityControlPlanDAOHE(); QualityControlPlan itemOnDB = qualityControlPlanDAOHE .findIsItempObj(item.getQualityControlPlanId(), 0L, 0L, false); if (itemOnDB != null) { item.setIsTemp(itemOnDB.getIsTemp()); if (item.getControlTarget() != null && itemOnDB.getControlTarget() != null) { if (!item.getControlTarget().equals(itemOnDB.getControlTarget())) { item.setIsTemp(1L); }// ww w. j a v a 2s . c o m } if (item.getNote() != null && itemOnDB.getNote() != null) { if (!item.getNote().equals(itemOnDB.getNote())) { item.setIsTemp(1L); } } if (item.getNoteForm() != null && itemOnDB.getNoteForm() != null) { if (!item.getNoteForm().equals(itemOnDB.getNoteForm())) { item.setIsTemp(1L); } } if (item.getPatternFrequence() != null && itemOnDB.getPatternFrequence() != null) { if (!item.getPatternFrequence().equals(itemOnDB.getPatternFrequence())) { item.setIsTemp(1L); } } if (item.getProductProcessDetail() != null && itemOnDB.getProductProcessDetail() != null) { if (!item.getProductProcessDetail().equals(itemOnDB.getProductProcessDetail())) { item.setIsTemp(1L); } } if (item.getTechnicalRegulation() != null && itemOnDB.getTechnicalRegulation() != null) { if (!item.getTechnicalRegulation().equals(itemOnDB.getTechnicalRegulation())) { item.setIsTemp(1L); } } if (item.getTestDevice() != null && itemOnDB.getTestDevice() != null) { if (!item.getTestDevice().equals(itemOnDB.getTestDevice())) { item.setIsTemp(1L); } } if (item.getTestMethod() != null && itemOnDB.getTestMethod() != null) { if (!item.getTestMethod().equals(itemOnDB.getTestMethod())) { item.setIsTemp(1L); } } } } item.setFileId(fileId); if (item.getQualityControlPlanId() != null) { getSession().merge(item); } else { getSession().save(item); } Long id = item.getQualityControlPlanId(); lstIdOfQualitys.add(id); } } String hql = "delete from QualityControlPlan m where m.fileId = :fileId "; if (!lstIdOfQualitys.isEmpty()) { hql += " and m.qualityControlPlanId not in (:lstIdOfQualitys)"; } Query query = getSession().createQuery(hql); query.setParameter("fileId", fileId); if (!lstIdOfQualitys.isEmpty()) { query.setParameterList("lstIdOfQualitys", lstIdOfQualitys); } query.executeUpdate(); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
private void saveProductInFile(List<ProductInFile> lstItems, Long fileId) { List<Long> lstIdOfProducts = new ArrayList(); if (lstItems != null && lstItems.size() > 0) { for (ProductInFile item : lstItems) { item.setFileId(fileId);//from w w w . ja v a 2s. c om if (item.getProductInFileId() != null) { getSession().update(item); } else { getSession().save(item); } Long id = item.getProductInFileId(); lstIdOfProducts.add(id); } } String hql = "delete from ProductInFile m where m.fileId = :fileId "; if (!lstIdOfProducts.isEmpty()) { hql += " and m.productInFileId not in (:lstIdOfProducts)"; } Query query = getSession().createQuery(hql); query.setParameter("fileId", fileId); if (!lstIdOfProducts.isEmpty()) { query.setParameterList("lstIdOfProducts", lstIdOfProducts); } query.executeUpdate(); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * 140616 - binhnt53 lay thong tin toan bo file ho so trong ho so ca nhan * * @param input/*from w ww. ja va2 s. c o m*/ * @param userId * @return */ public List getAttachsOfUserAttach(String input, Long userId) { String lstAttach[] = input.split(";"); String hql = "select u from UserAttachs u where "; hql += " u.createdBy =? "; hql += " and u.attachName in (:lstAttach) "; Query query = getSession().createQuery(hql); query.setParameter(0, userId); query.setParameterList("lstAttach", lstAttach); List lst = query.list(); return lst; }