List of usage examples for org.springframework.transaction.annotation Propagation REQUIRES_NEW
Propagation REQUIRES_NEW
To view the source code for org.springframework.transaction.annotation Propagation REQUIRES_NEW.
Click Source Link
From source file:es.emergya.bbdd.dao.HistoricoGPSHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public HistoricoGPS lastGPSForRecurso(String r) { HistoricoGPS res = null;/*from w w w . j a v a 2 s .c o m*/ if (r == null) return res; Session currentSession = getSession(); currentSession.flush(); res = ((Recurso) getSession().createCriteria(Recurso.class).add(Restrictions.eq("identificador", r)) .setMaxResults(1).uniqueResult()).getHistoricoGps(); return res; }
From source file:kr.co.exsoft.common.service.CommonService.java
/** * // w w w. j a v a2 s. c o m * <pre> * 1. : ?// - Base @Transactional * 2. : * </pre> * @Method Name : codeManager * @param codeVO * @param map * @return * @throws Exception */ @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = { Exception.class, SQLException.class }) public Map<String, Object> codeManager(CodeVO codeVO, HashMap<String, Object> map) throws Exception;
From source file:es.emergya.bbdd.dao.PatrullaHome.java
@SuppressWarnings("unchecked") @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public List<Patrulla> getAllTests() { List<Patrulla> res = new ArrayList<Patrulla>(0); try {/* ww w.j av a2 s. co m*/ Session currentSession = getSession(); currentSession.clear(); res = currentSession.createCriteria(Patrulla.class).addOrder(Order.asc("nombre")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); for (Patrulla p : res) for (Recurso r : p.getRecursos()) r.getId(); } catch (Throwable e) { log.error(e, e); } return res; }
From source file:es.emergya.bbdd.dao.UsuarioHome.java
@Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW) public boolean alreadyExists(String nombreUsuario) { if (nombreUsuario == null) return false; org.hibernate.Session currentSession = getSession(); currentSession.clear();//from w w w . j a v a 2 s . c om Integer count = (Integer) currentSession.createCriteria(Usuario.class) .add(Restrictions.eq("nombreUsuario", nombreUsuario)).setProjection(Projections.rowCount()) .uniqueResult(); return (count != 0); }
From source file:es.upm.fiware.rss.dao.impl.test.DbeSystemPropertiesDaoImplTest.java
@Transactional(propagation = Propagation.SUPPORTS) public void testgDeleteById() { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(Propagation.REQUIRES_NEW.value()); TransactionStatus status = transactionManager.getTransaction(def); dbeSystemPropertiesDao.deleteById("name2"); transactionManager.commit(status);/*from w w w. j av a 2 s.c om*/ Assert.assertTrue(dbeSystemPropertiesDao.getById("name2") == null); }
From source file:com.ibm.asset.trails.service.impl.ReconServiceImpl.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public AlertUnlicensedSw breakReconcileByAlert(Long alertId, Account account, String remoteUser, Set<UsedLicenseHistory> usedLicHis) { AlertUnlicensedSw alert = findAlertById(alertId); Reconcile reconcile = findReconcile(alert); clearUsedLicenses(reconcile, remoteUser); ReconcileH reconcileH = findReconcileHistory(alert); breakReconcileHistory(reconcile, reconcileH, alert, remoteUser, usedLicHis); createAlertHistory(alert);/*w ww . jav a2 s .c om*/ alert = openAlert(alert); breakReconcile(alert.getReconcile(), account, remoteUser); return alert; }
From source file:es.emergya.bbdd.dao.RecursoHome.java
@Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW) public Integer getTotal() { try {// w w w. j ava 2 s .c om Session currentSession = getSession(); currentSession.clear(); Criteria criteria = currentSession.createCriteria(Recurso.class).setProjection(Projections.rowCount()); Integer count = (Integer) criteria.uniqueResult(); return count.intValue(); } catch (Throwable t) { log.error(t, t); return -1; } }
From source file:es.emergya.bbdd.dao.ClienteConectadoHome.java
/** * /*from w w w . ja v a2 s .c o m*/ * @return el nmero de entradas en ClienteConectado */ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public int countClienteConectado() { log.debug("obteniendo el nmero de clientes conectados"); Criteria count = getSession().createCriteria(ClienteConectado.class); count.setProjection(Projections.rowCount()); return (Integer) count.list().get(0); }
From source file:com.ciphertool.sentencebuilder.dao.WordDao.java
/** * Updates a List of Words in batch./*from ww w.ja v a 2s .c om*/ * * @param wordBatch * the batch of Words * @return whether the update was successful */ @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean updateBatch(List<Word> wordBatch) { if (wordBatch == null || wordBatch.isEmpty()) { log.warn( "Attempted to update Words in batch which was found to be null or empty. Unable to continue, thus returning false."); return false; } Session session = sessionFactory.getCurrentSession(); for (Word word : wordBatch) { session.update(word); } return true; }
From source file:es.tid.fiware.rss.expenditureLimit.dao.impl.tests.DbeExpendControlDaoTest.java
@Test public void testUpdateExpendLimitDataForaUser() { BmService bmService = new BmService(); bmService.setNuServiceId(1);//from www . j a v a 2 s . c om BmCurrency bmCurrency = new BmCurrency(); bmCurrency.setNuCurrencyId(1); BmObCountry bmObCountry = new BmObCountry(); bmObCountry.setId(new BmObCountryId(1, 1)); List<DbeExpendControl> l = expLimitDao.getExpendDataForUserAppProvCurrencyObCountry("userId01", bmService, "app123456", bmCurrency, bmObCountry); Assert.assertTrue("Elements founds", l != null && l.size() == 3); Iterator<DbeExpendControl> it = l.iterator(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(Propagation.REQUIRES_NEW.value()); TransactionStatus status = transactionManager.getTransaction(def); while (it.hasNext()) { DbeExpendControl el = it.next(); if (el.getId().getTxElType().equalsIgnoreCase("daily")) { el.setFtExpensedAmount(new BigDecimal("0")); Date dt = new Date(new Date().getTime() + 23 * 36000 * 1000); el.setDtNextPeriodStart(dt); el.setTxNotifications(""); } else { el.setFtExpensedAmount(el.getFtExpensedAmount().add(new BigDecimal("22"))); el.setTxNotifications(el.getTxNotifications() + ", 50"); } expLimitDao.saveDbeExpendControl(el); } transactionManager.commit(status); l = expLimitDao.getExpendDataForUserAppProvCurrencyObCountry("userId01", bmService, "app123456", bmCurrency, bmObCountry); it = l.iterator(); while (it.hasNext()) { DbeExpendControl el = it.next(); if (el.getId().getTxElType().equalsIgnoreCase("daily")) { Assert.assertTrue("Daily accumulate: ", el.getFtExpensedAmount().floatValue() == 0); Assert.assertTrue("Notifications: ", el.getTxNotifications() == null || el.getTxNotifications().length() == 0); } else { Assert.assertTrue("Notifications: ", el.getTxNotifications().indexOf("50") > -1); } } }