public boolean chkDup() { DummyVOImpl dummy = (DummyVOImpl) getDummyVO1().getViewObject(); dummy.setQuery( "select art_id from uniform_title where nvl(upper(title),'0')='" + ParsiUtil.stringToZeroValue(getTitle()).toUpperCase().replaceAll("'", "''") + "' and labcol=" + getDBTransaction().getSession().getUserData().get("labcolno")); dummy.executeQuery(); return dummy.hasNext(); }
/** * Custom DML update/insert/delete logic here. * * @param operation the operation type * @param e the transaction event */ protected void doDML(int operation, TransactionEvent e) { try { if (operation != DML_DELETE) { setTitle(ParsiUtil.clearString(getTitle())); } if (operation == DML_INSERT) { if (chkDup()) throw new ParsiException("عنوان قراردادی تکراری است."); SequenceImpl si = new SequenceImpl("LIBRARY.SEQ_UNIFORM_TITLE_ART_ID", getDBTransaction()); setArtId(new DBSequence(si.getSequenceNumber())); } else if (operation == DML_UPDATE) { if (!ParsiUtil.stringToZeroValue(getTitle()).equals(getPostedAttribute(TITLE))) { if (chkDup()) throw new ParsiException("عنوان قراردادی تکراری است."); } } super.doDML(operation, e); } catch (Exception ex) { if (ex instanceof ParsiException) { throw new JboException(((ParsiException) ex).getMessage()); } else throw new JboException("خطا در ذخیره کردن رکورد عنوان قراردادی"); } }