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.epam.catgenome.manager.CytobandManagerTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testSaveAndLoadCytobands() throws Exception { // creates a corresponded test genome 'classpath:templates/reference/hp.genome.fa' final Reference reference = createGenome(); // adds cytological bands to corresponded chromosomes cytobandManager.saveCytobands(reference.getId(), getTemplate(HP_CYTOBANDS.getPath())); // checks that cytobands were saved under appropriate location reference.getChromosomes().stream().forEach(chromosome -> { if (!CHR_A5.equals(chromosome.getName())) { final File cytobandFile = fileManager.makeCytobandsFile(chromosome); assertTrue(String.format("No cytobands are found for %s chromosome.", chromosome.getName()), cytobandFile.exists()); }// www . ja v a 2 s . c o m }); // tries to load a track with cytobands for the first chromosome final Chromosome chromosome = reference.getChromosomes().get(0); final Track<Cytoband> track = cytobandManager.loadCytobands(chromosome.getId()); assertNotNull(String.format("No cytobands are found for %s chromosome.", chromosome.getName()), track); }
From source file:fi.hsl.parkandride.back.RequestLogDao.java
@Override @Transactional(readOnly = false, isolation = SERIALIZABLE, propagation = Propagation.REQUIRES_NEW) public void batchIncrement(Map<RequestLogKey, Long> nonNormalizedRequestLogCounts) { if (nonNormalizedRequestLogCounts.isEmpty()) { return;/* w w w . j ava 2 s. c o m*/ } // Normalize timestamps to hour final Map<RequestLogKey, Long> requestLogCounts = normalizeTimestamps(nonNormalizedRequestLogCounts); // Get rows to update final Set<DateTime> timestamps = extractFromKeys(requestLogCounts, key -> key.timestamp); final Map<RequestLogKey, Long> previousCountsForUpdate = getPreviousCountsForUpdate(timestamps); // Insert new sources and urls final BiMap<Long, String> allSources = insertNewSources( extractFromKeys(requestLogCounts, key -> key.source)); final BiMap<Long, String> allUrls = insertNewUrls(extractFromKeys(requestLogCounts, key -> key.urlPattern)); // Partition for insert/update final Map<Boolean, List<Map.Entry<RequestLogKey, Long>>> partitioned = requestLogCounts.entrySet().stream() .collect(partitioningBy(entry -> previousCountsForUpdate.containsKey(entry.getKey()))); // Insert non-existing rows insertNew(partitioned.get(Boolean.FALSE), allSources.inverse(), allUrls.inverse()); // Update updateExisting(partitioned.get(Boolean.TRUE), allSources.inverse(), allUrls.inverse()); }
From source file:be.peerassistedlearning.repository.ApplicationRepositoryTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testGetById() { applicationRepository.save(a1);//ww w . j a va 2 s . c o m assertNotNull(a1.getId()); assertNotNull(applicationRepository.findOne(a1.getId())); }
From source file:com.epam.catgenome.dao.ReferenceGenomeDaoTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testReferenceGenomeManagement() { // clear the list of chromosomes for test purposes reference.setChromosomes(Collections.emptyList()); // tests that a reference genome created in 'setup' can be retrieved by the known ID final Reference foundById = referenceGenomeDao.loadReferenceGenome(reference.getId()); assertNotNull("Reference genome isn't found by the given ID.", foundById); ReflectionAssert.assertReflectionEquals("Unexpected reference genome is loaded by ID.", reference, foundById);//from w ww . ja v a2 s. c o m // tests that a reference genome created in 'setup' can be retrieved in the list which contains // all chromosomes registered in the system final List<Reference> allReferenceGenomes = referenceGenomeDao.loadAllReferenceGenomes(); assertTrue("Collection of available reference genomes is empty, but should contain at least one value.", CollectionUtils.isNotEmpty(allReferenceGenomes)); final Optional<Reference> foundInList = allReferenceGenomes.stream() .filter(e -> reference.getId().equals(e.getId())).findFirst(); assertTrue("Reference genome isn't found by ID in the retrieved list.", foundInList.isPresent()); }
From source file:architecture.ee.web.community.announce.impl.DefaultAnnounceManager.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void addAnnounce(Announce announce) { Long announceId = announce.getAnnounceId(); if (announceId < 0) announceId = announceDao.nextId(); announce.setAnnounceId(announceId);/* ww w .j a va2 s. c om*/ announceDao.insert(announce); updateCache(announce); // fire event; }
From source file:be.peerassistedlearning.repository.StudentRepositoryTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testGetAll() { Student s1 = new Student("David", "paswoord", "davidopdebeeck@hotmail.com", Curriculum.TI, "david", UserType.ADMIN);/*from www. jav a 2s . c o m*/ Student s2 = new Student("Cedric", "paswoord", "cedricopdebeeck@hotmail.com", Curriculum.TI, "cedric", UserType.ADMIN); repository.save(s1); repository.save(s2); Collection<Student> list = Utils.makeCollection(repository.findAll()); assertNotNull(list); assertEquals(2, list.size()); }
From source file:com.parakhcomputer.web.dao.PersonDaoImpl.java
/** * Saves person. */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public Person save(Person person) { return em.merge(person); }
From source file:es.emergya.bbdd.dao.RolHome.java
@SuppressWarnings("unchecked") @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public List<Rol> getAll() { Session currentSession = getSession(); currentSession.clear();//from w ww . j a v a2 s . c om return currentSession.createCriteria(Rol.class).addOrder(Order.asc("nombre")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); }
From source file:architecture.ee.web.community.page.DefaultPageManager.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void updatePage(Page page) { updatePage(page, false); }
From source file:es.emergya.bbdd.dao.StreetHome.java
@Transactional(readOnly = false, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW) public boolean saveOrUpdate(Street s) { boolean res = true; if (s == null || s.getId() == null) { return res; }/*from w w w . j a v a 2 s.c om*/ Session currentSession = getSession(); currentSession.clear(); Street entity = get(s.getId()); if (entity != null) { entity.setCentroid(s.getCentroid()); currentSession.saveOrUpdate(entity); } return res; }