List of usage examples for org.hibernate FlushMode MANUAL
FlushMode MANUAL
To view the source code for org.hibernate FlushMode MANUAL.
Click Source Link
From source file:org.ednovo.gooru.web.listener.StartupListener.java
License:Open Source License
/** * Gets a Session for the SessionFactory that this listener uses. Note that * this just applies in single session mode! * <p>/*from w ww. j a va 2 s . co m*/ * The default implementation delegates to SessionFactoryUtils' getSession * method and sets the Session's flushMode to NEVER. * <p> * Can be overridden in subclasses for creating a Session with a custom * entity interceptor or JDBC exception translator. * * @param sessionFactory * the SessionFactory that this listener uses * @return the Session to use * @throws org.springframework.dao.DataAccessResourceFailureException * if the Session could not be created * @see org.springframework.orm.hibernate3.SessionFactoryUtils#getSession(SessionFactory, * boolean) * @see org.hibernate.FlushMode#NEVER */ protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException { Session session = sessionFactory.openSession(); session.setFlushMode(FlushMode.MANUAL); return session; }
From source file:org.egov.api.controller.EmployeeController.java
License:Open Source License
@SuppressWarnings("unchecked") public List<StateAware> getWorkflowItemsByUserAndWFType(final Long userId, final List<Long> owners, final String workFlowType, final int resultsFrom, final int resultsTo, String priority) throws ClassNotFoundException { if (!owners.isEmpty()) { Criterion criterion = Restrictions .not(Restrictions.conjunction().add(Restrictions.eq("state.status", StateStatus.STARTED)) .add(Restrictions.eq("createdBy.id", userId))); criterion = addPriorityCondition(criterion, priority); return entityQueryService.getSession() .createCriteria(Class .forName(workflowTypeService.getEnabledWorkflowTypeByType(workFlowType).getTypeFQN())) .setFirstResult(resultsFrom).setMaxResults(resultsTo).setFetchMode("state", FetchMode.JOIN) .createAlias("state", "state").setFlushMode(FlushMode.MANUAL).setReadOnly(true) .setCacheable(true).add(Restrictions.eq("state.type", workFlowType)) .add(Restrictions.in("state.ownerPosition.id", owners)) .add(Restrictions.ne("state.status", StateStatus.ENDED)).add(criterion) .addOrder(Order.desc("state.createdDate")).list(); }// w ww . j a v a 2 s . c o m return Collections.emptyList(); }
From source file:org.egov.api.controller.EmployeeController.java
License:Open Source License
@SuppressWarnings("unchecked") public Number getWorkflowItemsCountByWFType(final Long userId, final List<Long> owners, final String workFlowType, final String priority) throws ClassNotFoundException { if (!owners.isEmpty()) { Criterion criterion = Restrictions .not(Restrictions.conjunction().add(Restrictions.eq("state.status", StateStatus.STARTED)) .add(Restrictions.eq("createdBy.id", userId))); criterion = addPriorityCondition(criterion, priority); return (Number) entityQueryService.getSession() .createCriteria(Class .forName(workflowTypeService.getEnabledWorkflowTypeByType(workFlowType).getTypeFQN())) .setFetchMode("state", FetchMode.JOIN).createAlias("state", "state") .setFlushMode(FlushMode.MANUAL).setReadOnly(true).setCacheable(true) .setProjection(Projections.rowCount()).add(Restrictions.eq("state.type", workFlowType)) .add(Restrictions.in("state.ownerPosition.id", owners)) .add(Restrictions.ne("state.status", StateStatus.ENDED)).add(criterion).uniqueResult(); }/*from w w w . j a va2 s. c o m*/ return 0; }
From source file:org.egov.egf.web.actions.payment.SearchAdvanceRequisitionForPaymentAction.java
License:Open Source License
public String searchList() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); boolean isError = false; if (fromDate != null && toDate == null) { addFieldError("toDate", getText("search.toDate.null")); isError = true;/*from w w w . ja v a 2s. c o m*/ } if (toDate != null && fromDate == null) { addFieldError("fromDate", getText("search.fromDate.null")); isError = true; } if (!DateUtils.compareDates(toDate, fromDate)) { addFieldError("toDate", getText("fromDate.greaterthan.toDate")); isError = true; } if (!DateUtils.compareDates(new Date(), toDate)) { addFieldError("toDate", getText("toDate.greaterthan.currentdate")); isError = true; } if (isError) return "search"; setPageSize(30); super.search(); return "search"; }
From source file:org.egov.egf.web.actions.report.BalanceSheetReportAction.java
License:Open Source License
@Override public void prepare() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); super.prepare(); if (!parameters.containsKey("showDropDown")) { addDropdownData("departmentList", masterDataCache.get("egi-department")); addDropdownData("fundList", masterDataCache.get("egi-fund")); addDropdownData("functionList", masterDataCache.get("egi-function")); // addDropdownData("functionaryList", masterCache.get("egi-functionary")); // addDropdownData("fieldList", masterCache.get("egi-ward")); // addDropdownData("financialYearList", // getPersistenceService().findAllBy("from CFinancialYear where isActive=true and isActiveForPosting=true order by finYearRange desc ")); addDropdownData("financialYearList", persistenceService.findAllBy("from CFinancialYear order by finYearRange desc ")); }//from ww w. jav a2s . com }
From source file:org.egov.egf.web.actions.report.BankAdviceReportAction.java
License:Open Source License
@Override public void prepare() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); super.prepare(); addDropdownData("bankList", persistenceService.findAllBy( "select distinct b from Bank b , Bankbranch bb , Bankaccount ba WHERE bb.bank=b and ba.bankbranch=bb and ba.type in ('RECEIPTS_PAYMENTS','PAYMENTS') and b.isactive=true order by b.name")); if (bankbranch == null) addDropdownData("bankBranchList", Collections.EMPTY_LIST); else/*from w w w. j a v a 2 s .co m*/ addDropdownData("bankBranchList", persistenceService.findAllBy( "select distinct bb from Bankbranch bb,Bankaccount ba where bb.bank.id=? and ba.bankbranch=bb and ba.type in ('RECEIPTS_PAYMENTS','PAYMENTS') and bb.isactive=true", bank.getId())); if (bankaccount == null) addDropdownData("bankAccountList", Collections.EMPTY_LIST); else addDropdownData("bankAccountList", persistenceService .findAllBy("from Bankaccount where bankbranch.id=? and isactive=true", bankbranch.getId())); if (instrumentnumber == null) addDropdownData("chequeNumberList", Collections.EMPTY_LIST); else { List<Object[]> resultList = new ArrayList<Object[]>(); final List<InstrumentHeader> instrumentHeaderList = new ArrayList<InstrumentHeader>(); resultList = getPersistenceService().findAllBy("" + "SELECT ih.id, ih.instrumentNumber FROM InstrumentHeader ih, InstrumentVoucher iv, Paymentheader ph " + "WHERE ih.isPayCheque ='1' AND ih.bankAccountId.id = ? AND ih.statusId.description in ('New')" + " AND ih.statusId.moduletype='Instrument' AND iv.instrumentHeaderId = ih.id and ih.bankAccountId is not null " + "AND iv.voucherHeaderId = ph.voucherheader AND ph.bankaccount = ih.bankAccountId AND ph.type = '" + FinancialConstants.MODEOFPAYMENT_RTGS + "' " + "GROUP BY ih.instrumentNumber,ih.id", bankaccount.getId()); for (final Object[] obj : resultList) { InstrumentHeader ih = new InstrumentHeader(); ih = (InstrumentHeader) persistenceService.find("from InstrumentHeader where id=?", (Long) obj[0]); instrumentHeaderList.add(ih); } addDropdownData("chequeNumberList", instrumentHeaderList); } fullNameMonthMap = DateUtils.getAllMonthsWithFullNames(); final List<CFinancialYear> financialYears = financialYearDAO.getAllActiveFinancialYearList(); addDropdownData("financialYearsList", financialYears); }
From source file:org.egov.egf.web.actions.report.BankBookReportAction.java
License:Open Source License
@Override public void prepare() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); super.prepare(); if (!parameters.containsKey("skipPrepare")) { addDropdownData("bankList", egovCommon.getBankBranchForActiveBanks()); addDropdownData("accNumList", Collections.EMPTY_LIST); getHeaderFields();/*from w ww . j av a2 s .c om*/ if (headerFields.contains(Constants.DEPARTMENT)) addDropdownData("departmentList", persistenceService.findAllBy("from Department order by name")); if (headerFields.contains(Constants.FUNCTION)) addDropdownData("functionList", persistenceService .findAllBy("from CFunction where isactive=true and isnotleaf=false order by name")); if (headerFields.contains(Constants.FUNCTIONARY)) addDropdownData("functionaryList", persistenceService.findAllBy(" from Functionary where isactive=true order by name")); if (headerFields.contains(Constants.FUND)) addDropdownData("fundList", persistenceService .findAllBy(" from Fund where isactive=true and isnotleaf=false order by name")); if (headerFields.contains(Constants.FUNDSOURCE)) addDropdownData("fundsourceList", persistenceService.findAllBy(" from Fundsource where isactive=true order by name")); if (headerFields.contains(Constants.FIELD)) addDropdownData("fieldList", persistenceService.findAllBy(" from Boundary b where lower(b.boundaryType.name)='ward' ")); if (headerFields.contains(Constants.SCHEME)) addDropdownData("schemeList", Collections.EMPTY_LIST); if (headerFields.contains(Constants.SUBSCHEME)) addDropdownData("subschemeList", Collections.EMPTY_LIST); } }
From source file:org.egov.egf.web.actions.report.BillPaymentVoucherPrintAction.java
License:Open Source License
private void populateVoucher() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); if (!StringUtils.isBlank(parameters.get("id")[0])) { chequeNosList = new ArrayList<>(); final Long id = Long.valueOf(parameters.get("id")[0]); paymentHeader = persistenceService.getSession().get(Paymentheader.class, id); if (paymentHeader != null && paymentHeader.getType().equalsIgnoreCase(FinancialConstants.MODEOFPAYMENT_RTGS)) { paymentMode = "rtgs"; voucher = paymentHeader.getVoucherheader(); if (voucher != null) { final List<InstrumentVoucher> instrumentVoucherList = persistenceService .findAllBy("from InstrumentVoucher where voucherHeaderId.id=?", voucher.getId()); if (instrumentVoucherList != null && !instrumentVoucherList.isEmpty()) { final InstrumentHeader instrumentHeader = instrumentVoucherList.get(0) .getInstrumentHeaderId(); rtgsRefNo = instrumentHeader.getTransactionNumber(); rtgsDate = Constants.DDMMYYYYFORMAT2.format(instrumentHeader.getTransactionDate()); }/* ww w . j a va2 s . co m*/ generateVoucherReportList(); final Bankaccount bankAccount = paymentHeader.getBankaccount(); if (bankAccount != null) { bankName = bankAccount.getBankbranch().getBank().getName().concat("-") .concat(bankAccount.getBankbranch().getBranchname()); bankAccountNumber = bankAccount.getAccountnumber(); } miscBillDetailList = persistenceService .findAllBy("from Miscbilldetail where payVoucherHeader.id=?", voucher.getId()); } return; } if (paymentHeader != null) { voucher = paymentHeader.getVoucherheader(); final List<String> excludeChequeStatusses = new ArrayList<>(); excludeChequeStatusses.add(FinancialConstants.INSTRUMENT_CANCELLED_STATUS); excludeChequeStatusses.add(FinancialConstants.INSTRUMENT_SURRENDERED_FOR_REASSIGN_STATUS); excludeChequeStatusses.add(FinancialConstants.INSTRUMENT_SURRENDERED_STATUS); final List<InstrumentVoucher> instrumentVoucherList = persistenceService .findAllBy("from InstrumentVoucher where voucherHeaderId.id=?", voucher.getId()); if (instrumentVoucherList != null && !instrumentVoucherList.isEmpty()) for (final InstrumentVoucher instrumentVoucher : instrumentVoucherList) try { if (excludeChequeStatusses.contains( instrumentVoucher.getInstrumentHeaderId().getStatusId().getDescription())) continue; instrumentHeader = instrumentVoucher.getInstrumentHeaderId(); chequeNumber = instrumentVoucher.getInstrumentHeaderId().getInstrumentNumber(); chequeDate = Constants.DDMMYYYYFORMAT2 .format(instrumentVoucher.getInstrumentHeaderId().getInstrumentDate()); if (isInstrumentMultiVoucherMapped(instrumentVoucher.getInstrumentHeaderId().getId())) chequeNosList.add(chequeNumber + "-MULTIPLE"); else chequeNosList.add(chequeNumber); Long chequeNumberPass = Long.parseLong(chequeNumber); chequeNoList.add(chequeNumberPass); } catch (final NumberFormatException ex) { //Do nothing ? } generateVoucherReportList(); final Bankaccount bankAccount = paymentHeader.getBankaccount(); if (bankAccount != null) { bankName = bankAccount.getBankbranch().getBank().getName().concat("-") .concat(bankAccount.getBankbranch().getBranchname()); bankAccountNumber = bankAccount.getAccountnumber(); } // For Cash mode of payment, we need to take the payto of the associated cheque. if (paymentHeader.getType().equalsIgnoreCase(FinancialConstants.MODEOFPAYMENT_CASH) && instrumentHeader != null && instrumentHeader.getPayTo() != null) cashModePartyName = instrumentHeader.getPayTo(); } miscBillDetailList = persistenceService.findAllBy("from Miscbilldetail where payVoucherHeader.id=?", voucher.getId()); } Collections.sort(chequeNoList); chequeNumber = ""; for (final Long lval : chequeNoList) for (final String sval : chequeNosList) { Long chequeNoCompL; if (sval.contains(MULTIPLE)) chequeNoCompL = Long.parseLong(sval.substring(0, sval.lastIndexOf('-'))); else chequeNoCompL = Long.parseLong(sval); if (lval.equals(chequeNoCompL)) { chequeNumber = chequeNumber + sval + "/"; break; } } if (chequeNumber.length() > 1) chequeNumber = chequeNumber.substring(0, chequeNumber.length() - 1); }
From source file:org.egov.egf.web.actions.report.BillRegisterReportAction.java
License:Open Source License
@Action(value = "/report/billRegisterReport-newform") public String newform() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); isCompleteBillRegisterReport = false; loadDropdownData();//from w ww . j a v a 2 s. com toDate = fromDate = null; voucherHeader.reset(); exptype = billType = null; if (errorState) addActionError(getText("bill.register.report.system.error")); return NEW; }
From source file:org.egov.egf.web.actions.report.BillRegisterReportAction.java
License:Open Source License
@Action(value = "/report/billRegisterReport-searchform") public String searchform() { persistenceService.getSession().setDefaultReadOnly(true); persistenceService.getSession().setFlushMode(FlushMode.MANUAL); isCompleteBillRegisterReport = true; loadDropdownData();/*w w w. jav a2 s .c om*/ toDate = fromDate = null; voucherHeader.reset(); exptype = billType = null; if (errorState) addActionError(getText("bill.register.report.system.error")); return "completeBill"; }