List of usage examples for org.springframework.dao DataAccessException getMostSpecificCause
public Throwable getMostSpecificCause()
From source file:com.gst.portfolio.savings.service.DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl.java
@Transactional @Override//w w w . j a va 2s . com public CommandProcessingResult modifyFDApplication(final Long accountId, final JsonCommand command) { try { this.depositAccountDataValidator.validateFixedDepositForUpdate(command.json()); final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService .isSavingsInterestPostingAtCurrentPeriodEnd(); final Integer financialYearBeginningMonth = this.configurationDomainService .retrieveFinancialYearBeginningMonth(); final Map<String, Object> changes = new LinkedHashMap<>(20); final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler .assembleFrom(accountId, DepositAccountType.FIXED_DEPOSIT); checkClientOrGroupActive(account); account.modifyApplication(command, changes); account.validateNewApplicationState(DateUtils.getLocalDateOfTenant(), DepositAccountType.FIXED_DEPOSIT.resourceName()); if (!changes.isEmpty()) { updateFDAndRDCommonChanges(changes, command, account); final MathContext mc = MathContext.DECIMAL64; final boolean isPreMatureClosure = false; account.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth); this.savingAccountRepository.save(account); } boolean isLinkedAccRequired = command .booleanPrimitiveValueOfParameterNamed(transferInterestToSavingsParamName); // Save linked account information final Long savingsAccountId = command .longValueOfParameterNamed(DepositsApiConstants.linkedAccountParamName); AccountAssociations accountAssociations = this.accountAssociationsRepository.findBySavingsIdAndType( accountId, AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue()); if (savingsAccountId == null) { if (accountAssociations != null) { if (this.fromJsonHelper.parameterExists(DepositsApiConstants.linkedAccountParamName, command.parsedJson())) { this.accountAssociationsRepository.delete(accountAssociations); changes.put(DepositsApiConstants.linkedAccountParamName, null); if (isLinkedAccRequired) { this.depositAccountDataValidator.throwLinkedAccountRequiredError(); } } } else if (isLinkedAccRequired) { this.depositAccountDataValidator.throwLinkedAccountRequiredError(); } } else { boolean isModified = false; if (accountAssociations == null) { isModified = true; } else { final SavingsAccount savingsAccount = accountAssociations.linkedSavingsAccount(); if (savingsAccount == null || savingsAccount.getId() != savingsAccountId) { isModified = true; } } if (isModified) { final SavingsAccount savingsAccount = this.depositAccountAssembler .assembleFrom(savingsAccountId, DepositAccountType.SAVINGS_DEPOSIT); this.depositAccountDataValidator.validatelinkedSavingsAccount(savingsAccount, account); if (accountAssociations == null) { boolean isActive = true; accountAssociations = AccountAssociations.associateSavingsAccount(account, savingsAccount, AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue(), isActive); } else { accountAssociations.updateLinkedSavingsAccount(savingsAccount); } changes.put(DepositsApiConstants.linkedAccountParamName, savingsAccountId); this.accountAssociationsRepository.save(accountAssociations); } } return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(accountId) // .withOfficeId(account.officeId()) // .withClientId(account.clientId()) // .withGroupId(account.groupId()) // .withSavingsId(accountId) // .with(changes) // .build(); } catch (final DataAccessException dve) { handleDataIntegrityIssues(command, dve.getMostSpecificCause(), dve); return new CommandProcessingResult(Long.valueOf(-1)); } catch (final PersistenceException dve) { Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()); handleDataIntegrityIssues(command, throwable, dve); return new CommandProcessingResult(Long.valueOf(-1)); } }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
/** *//*from w ww . java 2 s. c o m*/ private void _jdoCreate(final Object object) { try { getCastorTemplate().create(object); } catch (DataAccessException ex) { Throwable cause = ex.getMostSpecificCause(); if (DuplicateIdentityException.class.isInstance(cause)) { throw new PersistenceException(cause); //TODO: //throw new DuplicateObjectException( cause ); } else { throw new PersistenceException(cause); } } }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
private void _jdoUpdate(final T object) { try {/*from w ww .j av a 2s . c o m*/ getCastorTemplate().update(object); } catch (DataAccessException ex) { throw new PersistenceException(ex.getMostSpecificCause()); } }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
private void _jdoRemove(final T object) { try {/*from w w w . j a va 2s .c o m*/ getCastorTemplate().remove(object); } catch (DataAccessException ex) { throw new PersistenceException(ex.getMostSpecificCause()); } }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
/** * Load the object of the specified identity. * If no such object exist, this method returns NULL. *///from w w w . j a v a2 s . c o m protected T _jdoLoad(final K id) { if (id == null) { return null; } Object p_object = null; try { p_object = getCastorTemplate().load(_objectType, id); } catch (DataAccessException ex) { Throwable cause = ex.getMostSpecificCause(); if (ObjectNotFoundException.class.isInstance(cause)) { p_object = null; } else { throw new PersistenceException(cause); } } T typedObject = _objectType.cast(p_object); // _afterLoad( typedObject ); return typedObject; }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
/** * Executes the specified OQL query.//from w ww . j a v a 2s . c o m */ private List<Object> _jdoExecuteQuery(final String oql, final Object[] params) { List<Object> results = null; try { results = getExtendedCastorTemplate().findByQuery(oql, params); } catch (DataAccessException ex) { throw new PersistenceException(ex.getMostSpecificCause()); } return results; }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDao.java
/** *//*from w w w . ja va2 s . com*/ protected final boolean _jdoIsPersistent(final Object object) { boolean persistent = false; try { persistent = getExtendedCastorTemplate().isPersistent(object); } catch (DataAccessException ex) { throw new PersistenceException(ex.getMostSpecificCause()); } return persistent; }
From source file:de.forsthaus.webui.security.user.UserDialogCtrl.java
/** * Saves the components to table. <br> * //from ww w . j av a 2s .co m * @throws InterruptedException */ @Secured({ btnCtroller_ClassPrefix + "btnSave" }) public void doSave() throws InterruptedException { System.out.println("doSave"); final SecUser anUser = getUser(); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // force validation, if on, than execute by component.getValue() // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (!isValidationOn()) { doSetValidation(); } // fill the object with the components data doWriteComponentsToBean(anUser); // validate password again usrPassword.getValue(); usrPasswordRetype.getValue(); /* if a language is selected get the object from the listbox */ Listitem item = lbox_usrLocale.getSelectedItem(); if (item != null) { ListModelList lml1 = (ListModelList) lbox_usrLocale.getListModel(); Language lang = (Language) lml1.get(item.getIndex()); anUser.setUsrLocale(lang.getLanLocale()); } // save it to database try { getUserService().saveOrUpdate(anUser); } catch (DataAccessException e) { ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString()); // Reset to init values doResetInitValues(); doReadOnly(); btnCtrl.setBtnStatus_Save(); return; } // now synchronize the listBox ListModelList lml = (ListModelList) listBoxUser.getListModel(); // Check if the object is new or updated // -1 means that the obj is not in the list, so it's new. if (lml.indexOf(anUser) == -1) { lml.add(anUser); } else { lml.set(lml.indexOf(anUser), anUser); } doReadOnly(); btnCtrl.setBtnStatus_Save(); // init the old values vars new doStoreInitValues(); }
From source file:de.forsthaus.webui.security.user.UserDialogCtrl.java
/** * Deletes a secUser object from database.<br> * //from www . ja v a 2 s . co m * @throws InterruptedException */ private void doDelete() throws InterruptedException { final SecUser anUser = getUser(); // Show a confirm box String msg = Labels.getLabel("message.Question.Are_you_sure_to_delete_this_record") + "\n\n --> " + anUser.getUsrLoginname() + " | " + anUser.getUsrFirstname() + " ," + anUser.getUsrLastname(); String title = Labels.getLabel("message.Deleting.Record"); MultiLineMessageBox.doSetTemplate(); if (MultiLineMessageBox.show(msg, title, MultiLineMessageBox.YES | MultiLineMessageBox.NO, MultiLineMessageBox.QUESTION, true, new EventListener() { @Override public void onEvent(Event evt) { switch (((Integer) evt.getData()).intValue()) { case MultiLineMessageBox.YES: deleteUser(); case MultiLineMessageBox.NO: break; // } } private void deleteUser() { /** * Prevent the deleting of the demo users */ try { if (anUser.getId() <= 14 && anUser.getId() >= 10) { ZksampleMessageUtils.doShowNotAllowedForDemoRecords(); return; } else { // delete from database try { getUserService().delete(anUser); } catch (DataAccessException e) { ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString()); } // now synchronize the listBox final ListModelList lml = (ListModelList) listBoxUser.getListModel(); // Check if the object is new or updated // -1 means that the obj is not in the list, so // it's // new.. if (lml.indexOf(anUser) == -1) { } else { lml.remove(lml.indexOf(anUser)); } } } catch (final Exception e) { // TODO: handle exception } userDialogWindow.onClose(); // close } } ) == MultiLineMessageBox.YES) { } }
From source file:de.forsthaus.webui.order.OrderPositionDialogCtrl.java
/** * Saves the components to table. <br> * /*from ww w . ja v a 2 s.c o m*/ * @throws InterruptedException */ public void doSave() throws InterruptedException { Orderposition anOrderposition = getOrderposition(); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // force validation, if on, than execute by component.getValue() // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (!isValidationOn()) { doSetValidation(); } artNr.getValue(); // additionally calculate new if (isDataChanged()) { doCalculate(); } // fill the objects with the components data doWriteComponentsToBean(anOrderposition); // save it to database try { getOrderService().saveOrUpdate(anOrderposition); } catch (DataAccessException e) { ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString()); // Reset to init values doResetInitValues(); doReadOnly(); btnCtrl.setBtnStatus_Save(); return; } /** Synchronize the listbox in the OrderDialog */ HibernateSearchObject<Orderposition> soOrderPosition = new HibernateSearchObject<Orderposition>( Orderposition.class, orderDialogCtrl.getPageSizeOrderPosition()); soOrderPosition.addFilter(new Filter("order", getOrder(), Filter.OP_EQUAL)); // deeper loading of a relation to prevent the lazy // loading problem. soOrderPosition.addFetch("article"); // Set the ListModel. getPlwOrderpositions().init(soOrderPosition, orderDialogCtrl.listBoxOrderOrderPositions, orderDialogCtrl.paging_ListBoxOrderOrderPositions); /** Synchronize the OrderList */ // Listbox listBoxOrderArticle = orderListCtrl.getListBoxOrderArticle(); // listBoxOrderArticle.setModel(orderDialogCtrl.listBoxOrderOrderPositions.getModel()); orderListCtrl.getListBoxOrderArticle().setModel(orderDialogCtrl.listBoxOrderOrderPositions.getModel()); // synchronize the TotalCount from the paging component orderListCtrl.paging_OrderArticleList .setTotalSize(orderDialogCtrl.paging_ListBoxOrderOrderPositions.getTotalSize()); doReadOnly(); btnCtrl.setBtnStatus_Save(); // init the old values vars new doStoreInitValues(); }