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:com.inkubator.sms.gateway.service.impl.IndexingLucenServiceImpl.java

@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
@Override/*from  ww  w .  j  a va 2  s  .  com*/
public void indexAll() throws Exception {
    System.out.println(" Do Indexingggggg");
    try {
        Session session = sessionFactory.getCurrentSession();

        FullTextSession fullTextSession = Search.getFullTextSession(session);
        fullTextSession.createIndexer().purgeAllOnStart(true).startAndWait();
        System.out.println(" Do Index Done");
    } catch (HibernateException | InterruptedException e) {
        throw e;
    }
}

From source file:net.cpollet.jixture.sample.service.impl.SimpleUserService.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public int getCommittedUsersCount() {
    return userDao.findAll().size();
}

From source file:br.edu.ifpb.blogsoon.manager.repositorios.avaliacao.AvaliacaoRepository.java

@Transactional(isolation = Isolation.READ_COMMITTED, value = "jpaTransactionManager")
public List<Avaliacao> findAvaliacaoByIdPostAndTipo(String idPost, AvaliacaoEnum tipo);

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

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
public void onMessage(Message message) {
    try {//from  w ww  . j  av a2s  .c o m
        TextMessage textMessage = (TextMessage) message;
        String json = textMessage.getText();
        RiwayatAkses riwayatAccess = (RiwayatAkses) jsonConverter.getClassFromJson(json, RiwayatAkses.class);
        riwayatAccess.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(14)));
        String data = StringUtils.substringAfter(riwayatAccess.getPathUrl(), riwayatAccess.getContextPath());
        HrmMenu hrmMenu = hrmMenuDao.getByPathRelative(data);
        riwayatAccess.setHrmMenu(hrmMenu);
        //            String b = StringUtils.reverse(riwayatAccess.getPathUrl());
        //            String c = StringUtils.substringBefore(b, "/");
        //            String d = StringUtils.reverse(c);
        //            riwayatAccess.setName(d);
        //            if (StringUtils.containsOnly(c, "htm")) {
        //                d = StringUtils.substringAfter(c, ".");
        //                riwayatAccess.setName(StringUtils.reverse(d));
        //            }
        riwayatAksesDao.save(riwayatAccess);
    } catch (JMSException | NumberFormatException ex) {
        LOGGER.error("Error", ex);
    }
}

From source file:gov.nih.nci.cabig.caaers.accesscontrol.dataproviders.FilteredDataLoader.java

@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void updateIndexByUserName(Authentication authentication) {
    String userName = SecurityUtils.getUserLoginName(authentication);
    long begin = System.currentTimeMillis();

    log.info("**BEGIN Updating Index for User " + userName);
    for (IdFetcher idFetcher : idFetchers) {
        long t1 = System.currentTimeMillis();
        List<IndexEntry> indexEntries = idFetcher.fetch(userName);
        long t2 = System.currentTimeMillis();
        log.info("TIME TOOK TO FETCH IDS " + idFetcher.getClass().getName() + " ..." + (t2 - t1) / 1000
                + " seconds");

        long t3 = System.currentTimeMillis();
        AbstractIndexDao indexDao = idFetcherIndexDaoMap.get(idFetcher);
        indexDao.updateIndex(userName, indexEntries);
        long t4 = System.currentTimeMillis();
        log.info("TIME TOOK TO UPDATE INDEX ..." + (t4 - t3) / 1000 + " seconds");
    }//from   ww w .  ja  v a  2s  . c om
    log.info("**END Updating Index for User " + userName + ", total time : "
            + (System.currentTimeMillis() - begin) / 1000 + " seconds");

}

From source file:annis.administration.DeleteCorpusDao.java

/**
 * Deletes a top level corpus, when it is already exists.
 * @param corpusName/*ww  w . j ava  2  s. c  o m*/
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void checkAndRemoveTopLevelCorpus(String corpusName) {
    if (existConflictingTopLevelCorpus(corpusName)) {
        log.info("delete conflicting corpus: {}", corpusName);
        List<String> corpusNames = new LinkedList<>();
        corpusNames.add(corpusName);
        deleteCorpora(getAnnisDao().mapCorpusNamesToIds(corpusNames), false);
    }
}

From source file:com.inkubator.sms.gateway.service.impl.SmsMessagesListener.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void onMessage(Message message) {
    try {//w  ww. java2s . c om

        LOGGER.info("Sending SMS Begin");
        TextMessage textMessage = (TextMessage) message;
        String json = textMessage.getText();
        SMSSend smss = (SMSSend) jsonConverter.getClassFromJson(json, SMSSend.class);
        LOGGER.info("Sending Messages " + smss.getContent());
        LOGGER.info("Sending Messages " + smss.getDestination());
        SmsActivity activity = new SmsActivity();
        activity.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(9)));
        activity.setContentSms(smss.getContent());
        activity.setDestination(smss.getDestination());
        activity.setIsSchedule(false);
        activity.setFromSms(smss.getFrom());
        activity.setIsSend(true);
        activity.setSendDate(new Date());
        activity.setSendTime(new Date());
        activity.setPriceSms(smss.getPricePerSms());
        smsActivityDao.save(activity);
        OutboundMessage msg = new OutboundMessage(smss.getDestination(), smss.getContent());
        msg.setFlashSms(false);
        if (smss.getModemId() == null) {
            Service.getInstance().sendMessage(msg);
        } else {
            Service.getInstance().sendMessage(msg, smss.getModemId());
        }

        LOGGER.info("Sending SMS Done");
    } catch (Exception ex) {
        LOGGER.error("Error", ex);
    }
    //        } catch (JMSException | TimeoutException | GatewayException | IOException | InterruptedException ex) {
    //            LOGGER.error("Error", ex);
    //        }
}

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

@SuppressWarnings("unchecked")
@Override/*from w ww. j av  a2s . c  om*/
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class)
public void onMessage(Message message) {
    try {
        TextMessage textMessage = (TextMessage) message;
        String json = textMessage.getText();
        Gson gson = new GsonBuilder().create();
        JsonObject jsonObject = (JsonObject) gson.fromJson(json, JsonObject.class);
        String locale = jsonObject.get("locale").getAsString();
        String userEmail = jsonObject.get("userEmail").getAsString();

        List<String> toSend = new ArrayList<>();
        List<String> toSentCC = new ArrayList<String>();
        List<String> toSentBCC = new ArrayList<String>();
        toSend.add(userEmail);
        toSentCC.add("rizky.maulana@incubatechnology.com");
        toSentCC.add("rizkykojek@gmail.com");
        toSentCC.add("rizal2_dfhr@yahoo.com");
        VelocityTempalteModel vtm = new VelocityTempalteModel();
        vtm.setFrom(ownerEmail);
        vtm.setTo(toSend.toArray(new String[toSend.size()]));
        vtm.setCc(toSentCC.toArray(new String[toSentCC.size()]));
        vtm.setBcc(toSentBCC.toArray(new String[toSentBCC.size()]));

        Map maptoSend = new HashMap();
        maptoSend.put("startDate", jsonObject.get("startDate").getAsString());
        maptoSend.put("endDate", jsonObject.get("endDate").getAsString());
        maptoSend.put("userName", jsonObject.get("userName").getAsString());
        maptoSend.put("userNik", jsonObject.get("userNik").getAsString());
        maptoSend.put("ownerAdministrator", ownerAdministrator);
        maptoSend.put("ownerCompany", ownerCompany);
        maptoSend.put("applicationUrl", applicationUrl);
        maptoSend.put("applicationName", applicationName);
        List<String> listSchedule = gson.fromJson(jsonObject.get("listSchedule").getAsString(),
                new TypeToken<List<String>>() {
                }.getType());
        maptoSend.put("listSchedule", listSchedule);
        if (StringUtils.equals(locale, "en")) {
            vtm.setSubject("Employee Working Schedule");
            vtm.setTemplatePath("email_employee_working_schedule_en.vm");
        } else {
            vtm.setSubject("Jadwal Kerja Karyawan");
            vtm.setTemplatePath("email_employee_working_schedule.vm");
        }

        velocityTemplateSender.sendMail(vtm, maptoSend);
    } catch (Exception ex) {
        LOGGER.error("Error", ex);
    }
}

From source file:net.longfalcon.newsj.Config.java

@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
public void init() {
    properties = new Properties();
    for (Resource resource : propertyLocations) {
        try {/*from  w  ww .j a  va2s.  co m*/
            properties.load(resource.getInputStream());
        } catch (IOException e) {
            _log.error("Unable to read from resource " + resource.getFilename());
        }
    }
    defaultSite = siteDAO.getDefaultSite();
}

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

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
public HrmRole getEntiyByPK(Long id) throws Exception {
    return this.hrmRoleDao.getEntiyByPK(id);
}