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:org.finra.herd.service.impl.EmrServiceImpl.java
/** * {@inheritDoc}/*from w w w .ja v a 2 s. c om*/ * <p/> * This implementation starts a new transaction. */ @NamespacePermission(fields = "#emrClusterAlternateKeyDto?.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public EmrCluster getCluster(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose, String accountId, Boolean retrieveInstanceFleets) throws Exception { return getClusterImpl(emrClusterAlternateKeyDto, emrClusterId, emrStepId, verbose, accountId, retrieveInstanceFleets); }
From source file:gov.nih.nci.cabig.caaers.domain.repository.UserRepositoryImpl.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, noRollbackFor = MailException.class) public void createOrUpdateUser(User user, String changeURL) { if (user.getCsmUser().getUserId() == null) { createCSMUser(user);//from w ww . j av a 2 s . c o m save(user); sendCreateAccountEmail(user, changeURL); } else { updateCSMUser(user, true); if (user.getId() == null) { save(user); } sendUpdateAccountEmail(user); } }
From source file:org.brekka.pegasus.core.services.impl.PegasusPrincipalServiceImpl.java
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void loginAndBind(final PegasusPrincipalAware principalSource, final String password, final Organization organization, final boolean restoreRequired) { Stopwatch sw = Stopwatch.createStarted(); PegasusPrincipalImpl pegasusPrincipal = (PegasusPrincipalImpl) principalSource.getPegasusPrincipal(); synchronized (pegasusPrincipal) { if (pegasusPrincipal.getMemberContext() != null) { return; }/*from www . j a va 2s. co m*/ try { AuthenticationToken authenticationToken = authenticationTokenDAO .retrieveById(pegasusPrincipal.getAuthenticationTokenId()); Member member = memberDAO.retrieveByAuthenticationToken(authenticationToken); if (member.getStatus() != ActorStatus.ACTIVE) { throw new DisabledException(String.format("Member '%s' account is disabled", member.getId())); } Vault vault = member.getDefaultVault(); member = narrow(member, Member.class); MemberContextImpl memberContext = new MemberContextImpl(member); Profile activeProfile = profileService.retrieveProfile(member); memberContext.setActiveProfile(activeProfile != null ? activeProfile : new Profile()); // Vault service will use this pegasusPrincipal.setMemberContext(memberContext); threadLocalPrincipals.set(pegasusPrincipal); vault = narrow(vaultService.openVault(vault.getId(), password), Vault.class); member.setDefaultVault(vault); if (organization != null) { memberService.activateOrganization(organization); } if (restoreRequired) { prepareRestore(pegasusPrincipal, vault); } pegasusPrincipal.setOrganizationId(organization != null ? organization.getId() : null); if (log.isInfoEnabled()) { log.info(String.format("Pegasus login for '%s' with organization '%s', took %d ms", pegasusPrincipal.getName(), organization != null ? organization.getName() : null, sw.elapsed(TimeUnit.MILLISECONDS))); } } catch (RuntimeException e) { // We need to bind early to support the latter restore operations, however if an error occurs, make sure to unbind the broken context. pegasusPrincipal.setMemberContext(null); throw e; } } }
From source file:es.emergya.bbdd.dao.ClienteConectadoHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Throwable.class) public void addNewClienteConectado(Usuario user, Long fsUid) { ClienteConectado cliente = new ClienteConectado(); cliente.setId(fsUid);//ww w . j a v a 2 s .c o m cliente.setUsuario(user); cliente.setUltimaConexion(new Date()); getSession().save(cliente); }
From source file:kr.co.exsoft.common.service.CommonService.java
/** * /*from www .j a v a2s .com*/ * <pre> * 1. : ?// * 2. : * </pre> * @Method Name : menuAuthManager * @param menuAuthVO * @param map * @return Map * @throws Exception */ @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = { Exception.class, SQLException.class }) public Map<String, Object> menuAuthManager(List<MenuAuthVO> menuAuthList, HashMap<String, Object> map) throws Exception;
From source file:be.peerassistedlearning.repository.ReviewRepositoryTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testGetAll() { Review review = new Review(text, s1, l, 5, 7, 6, 4, false); Review review1 = new Review(text, s2, l, 5, 4, 8, 6, true); reviewRepository.save(review);/*from w w w.j av a2 s .c o m*/ reviewRepository.save(review1); assertNotNull(review.getId()); assertNotNull(review1.getId()); Collection<Review> list = Utils.makeCollection(reviewRepository.findAll()); assertNotNull(list); Assert.assertEquals(2, list.size()); }
From source file:es.emergya.bbdd.dao.HistoricoGPSHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public Calendar firstGPSForRecurso(String r) { HistoricoGPS res = null;//from w w w.ja va 2 s. c om if (r == null) return null; Session currentSession = getSession(); currentSession.flush(); res = (HistoricoGPS) getSession().createCriteria(HistoricoGPS.class).add(Restrictions.eq("recurso", r)) .addOrder(Order.asc("marcaTemporal")).setMaxResults(1).uniqueResult(); if (res == null || res.getMarcaTemporal() == null) return null; Calendar resultado = Calendar.getInstance(); resultado.setTime(res.getMarcaTemporal()); return resultado; }
From source file:org.jasig.schedassist.impl.relationship.CSVRelationshipDataSourceImpl.java
/** * This method deletes all existing rows from the isis_records table, then invokes * {@link #batchLoadData(Resource)} to refresh it. * /*from w w w. j av a2 s .c om*/ * This method is marked with Spring's {@link Transactional} annotation, and if * the Scheduling Assistant application is running should only be executed when transactional * support is available. * * @see Transactional * @param resource * @throws IOException */ @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW) public synchronized void reloadData() { final String propertyValue = System.getProperty("org.jasig.schedassist.runScheduledTasks", "true"); if (Boolean.parseBoolean(propertyValue)) { if (isResourceUpdated(csvResource)) { LOG.info("resource updated, reloading advisorList data"); //List<StudentAdvisorAssignment> records = readResource(advisorListResource, currentTerm); List<CSVRelationship> records = new ArrayList<CSVRelationship>(); try { records = readCSVResource(csvResource); } catch (IOException e) { LOG.error("caught IOException reading csv data source", e); return; } if (records.isEmpty()) { LOG.warn("resource returned empty set, skipping reloadData"); return; } LOG.info("deleting all existing records from csv_relationships table"); StopWatch stopWatch = new StopWatch(); stopWatch.start(); this.getJdbcTemplate().execute("delete from csv_relationships"); long deleteTime = stopWatch.getTime(); LOG.info("finished deleting existing (" + deleteTime + " msec), starting batch insert"); stopWatch.reset(); stopWatch.start(); SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(records.toArray()); this.getSimpleJdbcTemplate().batchUpdate( "insert into csv_relationships (owner_id, visitor_id, rel_description) values (:ownerIdentifier, :visitorIdentifier, :relationshipDescription)", batch); long insertTime = stopWatch.getTime(); stopWatch.stop(); LOG.info("batch insert complete (" + insertTime + " msec)"); LOG.info("reloadData complete (total time: " + (insertTime + deleteTime) + " msec)"); this.lastReloadTimestamp = new Date(); try { this.resourceLastModified = csvResource.lastModified(); } catch (IOException e) { LOG.debug("ignoring IOException from accessing Resource.lastModified()"); } } else { LOG.info("resource not modified since last reload, skipping"); } } else { LOG.debug("ignoring reloadData as 'org.jasig.schedassist.runScheduledTasks' set to false"); } }
From source file:es.upm.fiware.rss.dao.impl.test.DbeSystemPropertiesDaoImplTest.java
@Transactional(propagation = Propagation.SUPPORTS) public void testhDeleteAll() { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(Propagation.REQUIRES_NEW.value()); TransactionStatus status = transactionManager.getTransaction(def); dbeSystemPropertiesDao.deleteAll();//from w w w .j a va 2 s.c o m transactionManager.commit(status); Assert.assertTrue(dbeSystemPropertiesDao.getAll().size() == 0); }
From source file:architecture.ee.web.attachment.DefaultAttachmentManager.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public Attachment saveAttachment(Attachment attachment) { Date now = new Date(); Attachment attachmentToUse = attachment; if (attachmentToUse.getAttachmentId() > 0) { attachmentCache.remove(attachmentToUse.getAttachmentId()); attachmentToUse.setModifiedDate(now); attachmentDao.updateAttachment(attachmentToUse); attachmentCache.remove(attachmentToUse.getAttachmentId()); } else {// w ww. j av a 2s . c om attachmentToUse.setCreationDate(now); attachmentToUse.setModifiedDate(now); attachmentToUse = attachmentDao.createAttachment(attachmentToUse); } try { if (attachmentToUse.getInputStream() != null) { attachmentDao.saveAttachmentData(attachmentToUse, attachmentToUse.getInputStream()); Collection<File> files = FileUtils.listFiles(getAttachmentCacheDir(), FileFilterUtils.prefixFileFilter(attachment.getAttachmentId() + ""), null); for (File file : files) { FileUtils.deleteQuietly(file); } } return getAttachment(attachment.getAttachmentId()); } catch (Exception e) { throw new SystemException(e); } }