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:com.jaspersoft.jasperserver.api.engine.common.service.impl.HibernateLoggingService.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false) public void purge() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -getMaximumAge()); Date last = cal.getTime();/*from w ww.java 2s. c o m*/ if (log.isDebugEnabled()) { log.debug("Purging log events older than " + last); } getHibernateTemplate().bulkUpdate("delete RepoLogEvent e where e.occurrenceDate < ?", last); }
From source file:es.emergya.bbdd.dao.ClienteConectadoHome.java
/** * Elimina los clientes conectados que cuya fecha de ltima actualizacin * sea anterior a <code>secondsOld</code> segundos antes de la consulta. * /*from w w w. j av a 2 s. c o m*/ * @param secondsOld * @return el nmero de filas borradas. */ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Throwable.class) public int cleanOldClienteConectado(int secondsOld) { Session session = getSession(); String sqlDelete = "DELETE FROM clientes_conectados c WHERE current_timestamp - c.ultima_conexion > interval '" + secondsOld + " seconds'"; int deleted = session.createSQLQuery(sqlDelete).executeUpdate(); return deleted; }
From source file:be.peerassistedlearning.repository.CourseRepositoryTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testGetByShortName() { Course c1 = new Course("MBI80x", ".NET Programmeren", ".NET", Curriculum.TI, 3); repository.save(c1);//from www .j a va2s. c om Course c2 = repository.findByShortName(c1.getShortName()); assertNotNull(c2); assertEquals(c1, c2); }
From source file:com.ciphertool.sentencebuilder.dao.WordDao.java
/** * Updates a Word.//ww w . j a va 2 s. c o m * * @param word * the Word to update * @return whether the update was successful */ @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean update(Word word) { if (word == null) { log.warn("Attempted to update null Word. Unable to continue, thus returning false."); return false; } Session session = sessionFactory.getCurrentSession(); session.update(word); return true; }
From source file:de.hska.ld.core.logging.ExceptionLoggerImpl.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false) private UUID save(ExceptionLogEntry entry) { entityManager.persist(entry); return entry.getId(); }
From source file:org.trpr.platform.core.impl.persistence.PersistenceDelegate.java
/** * Persists the specified PersistentEntity instances using the specified PersistenceProvider instances, matched by index positions. * Note that this method is transactional by default. * It is advisable to use {@link PersistenceManagerProvider#makePersistent(PersistentEntity[])} instead of calling this method directly. * @param entities the PersistentEntity instances to persist * @param providers the PersistenceProvider instances to use in persistence * @return PersistentEntity instances that were persisted * @throws PersistenceException in case of persistence errors *//*from www .ja v a 2 s . com*/ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, rollbackForClassName = { "Exception" }) public PersistentEntity[] makePersistent(PersistentEntity[] entities, PersistenceProvider[] providers) throws PersistenceException { for (int i = 0; i < entities.length; i++) { providers[i].makePersistent(entities[i]); } return entities; }
From source file:es.upm.fiware.rss.expenditureLimit.dao.impl.tests.DbeExpendControlDaoTest.java
@Transactional(propagation = Propagation.SUPPORTS) public void testUpdateExpendLimitDataForaUser() { BmCurrency bmCurrency = new BmCurrency(); bmCurrency.setNuCurrencyId(1);/* w ww . j ava 2 s.c o m*/ List<DbeExpendControl> l = expLimitDao.getExpendDataForUserAppProvCurrency("userId01", "agg123", "app123456", bmCurrency); 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.getExpendDataForUserAppProvCurrency("userId01", "agg123", "app123456", bmCurrency); 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().contains("50")); } } }
From source file:es.tid.fiware.rss.dao.impl.test.DbeSystemPropertiesDaoImplTest.java
@Test public void testfDelete() { DbeSystemProperties c = dbeSystemPropertiesDao.getById("name"); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(Propagation.REQUIRES_NEW.value()); TransactionStatus status = transactionManager.getTransaction(def); dbeSystemPropertiesDao.delete(c);/*from w w w. j a v a 2 s . co m*/ transactionManager.commit(status); Assert.assertTrue(dbeSystemPropertiesDao.getById("name") == null); }
From source file:com.google.ie.business.service.impl.ShardedCounterServiceImpl.java
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void incrementNegativePoints(String parentKey) { logger.debug("Incrementing negative point in sharded counter for parent key: " + parentKey); if (parentKey == null) { logger.debug("Parent key value is null : "); return;/*w w w .ja v a2 s . com*/ } Random generator = new Random(); int shardNum = generator.nextInt(DaoConstants.SHARDED_COUNTERS); List<ShardedCounter> shards = shardedCounterDao.getShardsByParentKeyAndShardNum(parentKey, shardNum); ShardedCounter shard = null; ShardedCounter shardToUpdate = null; if (shards == null || shards.isEmpty()) { shardToUpdate = new ShardedCounter(parentKey); shardToUpdate.setNegativePoint(DaoConstants.ONE); shardToUpdate.setShardNumber(shardNum); } else { shard = shards.get(0); shardToUpdate = getShardCopy(shard); shardToUpdate.setNegativePoint(shardToUpdate.getNegativePoint() + DaoConstants.ONE); } shardedCounterDao.createOrUpdateShardedCounter(shardToUpdate); logger.debug("Negative point incremented in sharded counter for parent key : " + parentKey); }
From source file:es.emergya.comunications.MessageGenerator.java
/** * @param id/* ww w . j a v a2 s . co m*/ * Id del mensaje que se debe comprobar si existe o no * @return Si el mensaje con id de bandeja de salida <code>id</code> aun * existe en la base de datos. */ @Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW) public static boolean messageExists(Long id) { return bandejaSalidaDAO.exists(id); }