Example usage for org.springframework.transaction.annotation Isolation READ_COMMITTED

List of usage examples for org.springframework.transaction.annotation Isolation READ_COMMITTED

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Isolation READ_COMMITTED.

Prototype

Isolation READ_COMMITTED

To view the source code for org.springframework.transaction.annotation Isolation READ_COMMITTED.

Click Source Link

Document

A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur.

Usage

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 . ja va  2 s.  c  o  m*/
 * 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:com.inkubator.hrm.service.impl.SystemLetterReferenceServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void delete(SystemLetterReference entity) throws Exception {
    this.systemLetterReferenceDao.delete(entity);
}

From source file:com.inkubator.hrm.service.impl.HrmRoleServiceImpl.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
public void delete(HrmRole entity) throws Exception {
    this.hrmRoleDao.delete(entity);
}

From source file:org.alienlabs.hatchetharry.service.DataGenerator.java

@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = { "PATH_TRAVERSAL_IN",
        "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS" }, justification = "the difference is in fake.setDeckArchive() ")
@Override/*from w  w  w  .ja  v a 2  s .c  o  m*/
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
public void afterPropertiesSet() throws Exception {
    if ((this.generateCardCollection) && (this.cardCollectionDao.count() == 0)) {
        try {
            final JAXBContext context = JAXBContext.newInstance(CardCollectionRootElement.class);
            final Unmarshaller um = context.createUnmarshaller();
            final CardCollectionRootElement cardCollection = (CardCollectionRootElement) um
                    .unmarshal(new File(ResourceBundle.getBundle(DataGenerator.class.getCanonicalName())
                            .getString("AllCardsInCollectionUntilReturnToRavnica")));

            final Object[] array = cardCollection.getCardCollectionList().toArray();

            for (final Object element : array) {
                this.cardCollectionDao.save((CardCollection) element);
            }
        } catch (final JAXBException e) {
            LOGGER.error("Error while generating card collection!", e);
        }
    }

    if ((this.generateData) && (null == this.persistenceService.getDeckArchiveByName("Aura Bant"))) {
        final Path path = Paths.get(
                ResourceBundle.getBundle(DataGenerator.class.getCanonicalName()).getString("AuraBantDeck"));
        final byte[] content = Files.readAllBytes(path);
        final String deckContent = new String(content, "UTF-8");
        this.importDeckService.importDeck(deckContent, "Aura Bant", false);
    }

    DataGenerator.LOGGER.info("preparing to import decks");

    if (((null == this.persistenceService.getDeckArchiveByName("aggro-combo Red / Black"))
            && (null == this.persistenceService.getDeckArchiveByName("burn mono-Red")))
            || ((this.persistenceService.getDeckByDeckArchiveName("aggro-combo Red / Black").getCards()
                    .isEmpty())
                    || (this.persistenceService.getDeckByDeckArchiveName("burn mono-Red").getCards()
                            .isEmpty()))) {
        DataGenerator.LOGGER.info("importing decks");

        final DeckArchive da1;
        final DeckArchive da2;
        final Deck deck1;
        final Deck deck2;

        if (null == this.persistenceService.getDeckArchiveByName("aggro-combo Red / Black")) {
            da1 = new DeckArchive();
            da1.setDeckName("aggro-combo Red / Black");
            this.persistenceService.saveOrUpdateDeckArchive(da1);
            deck1 = new Deck();
            deck1.setPlayerId(1L);
            deck1.setDeckArchive(da1);
        } else {
            da1 = this.persistenceService.getDeckArchiveByName("aggro-combo Red / Black");
            deck1 = this.persistenceService.getDeckByDeckArchiveName("aggro-combo Red / Black");
        }

        if (null == this.persistenceService.getDeckArchiveByName("burn mono-Red")) {
            da2 = new DeckArchive();
            da2.setDeckName("burn mono-Red");
            this.persistenceService.saveOrUpdateDeckArchive(da2);
            deck2 = new Deck();
            deck2.setPlayerId(2L);
            deck2.setDeckArchive(da2);
        } else {
            da2 = this.persistenceService.getDeckArchiveByName("burn mono-Red");
            deck2 = this.persistenceService.getDeckByDeckArchiveName("burn mono-Red");
        }

        for (int j = 1; j < 3; j++) {
            if (((j == 1) && ((deck1.getCards() == null) || (deck1.getCards().isEmpty())))
                    || (((j == 2) && ((deck2.getCards() == null) || (deck2.getCards().isEmpty()))))) {
                for (int i = 0; i < 60; i++) {
                    // A CollectibleCard can be duplicated: lands, normal
                    // cards
                    //
                    MagicCard card = null;

                    final CollectibleCard cc = new CollectibleCard();
                    cc.setTitle(j == 1 ? DataGenerator.TITLES1[i] : DataGenerator.TITLES2[i]);
                    cc.setDeckArchiveId(j == 1 ? da1.getDeckArchiveId() : da2.getDeckArchiveId());

                    // A CollectibleCard can be duplicated: lands, normal
                    // cards
                    // which may be present 4 times in a Deck...
                    this.persistenceService.saveCollectibleCard(cc);

                    if (j == 1) {
                        card = new MagicCard("cards/" + DataGenerator.TITLES1[i] + "_small.jpg",
                                "cards/" + DataGenerator.TITLES1[i] + ".jpg",
                                "cards/" + DataGenerator.TITLES1[i] + "Thumb.jpg", DataGenerator.TITLES1[i], "",
                                "", null, Integer.valueOf(0));
                        card.setDeck(deck1);
                    } else {
                        card = new MagicCard("cards/" + DataGenerator.TITLES2[i] + "_small.jpg",
                                "cards/" + DataGenerator.TITLES2[i] + ".jpg",
                                "cards/" + DataGenerator.TITLES2[i] + "Thumb.jpg", DataGenerator.TITLES2[i], "",
                                "", null, Integer.valueOf(0));
                        card.setDeck(deck2);
                    }

                    card.setGameId(-1L);
                    card.setUuidObject(UUID.randomUUID());
                    card.setX(16L);
                    card.setY(16L);
                    card.setZone(CardZone.LIBRARY);

                    if (j == 1) {
                        final List<MagicCard> cards = deck1.getCards();
                        cards.add(card);
                        deck1.setCards(cards);
                    } else {
                        final List<MagicCard> cards = deck2.getCards();
                        cards.add(card);
                        deck2.setCards(cards);
                    }
                }
            } else {
                if (j == 1) {
                    final List<MagicCard> cards = this.persistenceService
                            .getAllCardsFromDeck("aggro-combo Red / Black");
                    deck1.setCards(cards);
                } else {
                    final List<MagicCard> cards = this.persistenceService.getAllCardsFromDeck("burn mono-Red");
                    deck2.setCards(cards);
                }
            }

            if (j == 1) {
                this.persistenceService.saveOrUpdateDeck(deck1);
                this.persistenceService.saveOrUpdateDeckArchive(da1);
                DataGenerator.LOGGER.info("updated deck 1");
            } else {
                this.persistenceService.saveOrUpdateDeck(deck2);
                this.persistenceService.saveOrUpdateDeckArchive(da2);
                DataGenerator.LOGGER.info("updated deck 2");
            }
        }
    }
}

From source file:com.inkubator.hrm.service.impl.ProscessToApproveServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void delete(ProscessToApprove entity) throws Exception {
    this.proscessToApproveDao.delete(entity);
}

From source file:com.inkubator.hrm.service.impl.OhsaIncidentDocumentServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, noRollbackFor = IOException.class)
public void delete(OhsaIncidentDocument t) throws Exception {
    //remove physical file
    try {/*from   ww  w  .  j  a  v  a 2 s. c o  m*/
        File oldFile = new File(t.getUploadedPath());
        oldFile.delete();
    } catch (Exception e) {
        //if any error when removing file, system will continue deleting the record
    }
    this.ohsaIncidentDocumentDao.delete(t);
}

From source file:com.inkubator.hrm.service.impl.TempAttendanceRealizationServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

public void delete(TempAttendanceRealization tempAttendanceRealization) throws Exception {
    tempAttendanceRealizationDao.delete(tempAttendanceRealization);
}

From source file:com.inkubator.hrm.service.impl.BioSertifikasiServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, noRollbackFor = IOException.class)
public void delete(BioSertifikasi t) throws Exception {
    //remove physical file
    try {/*from ww w  .  j a  v a 2  s.c om*/
        File oldFile = new File(t.getUploadPath());
        oldFile.delete();
    } catch (Exception e) {
        //if any error when removing file, system will continue deleting the record
    }

    //remove entity
    bioSertifikasiDao.delete(t);
}

From source file:com.inkubator.hrm.service.impl.TempAttendanceRealizationServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void save(TempAttendanceRealization tempAttendanceRealization) throws Exception {
    //Uncomment below if u have unik code
    //long totalDuplicates = tempAttendanceRealizationDao.getTotalByCode(tempAttendanceRealization.getCode());
    //if (totalDuplicates > 0) {
    //throw new BussinessException("tempAttendanceRealization.error_duplicate_code")
    //}/*from w  w w .  jav a  2 s  .c  om*/
    tempAttendanceRealization.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12)));
    tempAttendanceRealization.setCreatedBy(UserInfoUtil.getUserName());
    tempAttendanceRealization.setCreatedOn(new Date());
    tempAttendanceRealizationDao.save(tempAttendanceRealization);
}

From source file:com.inkubator.hrm.service.impl.SystemLetterReferenceServiceImpl.java

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 50)
public List<SystemLetterReference> getAllData() throws Exception {
    return systemLetterReferenceDao.getAllData();
}