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.NotificationUserMessagesListener.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class)
public void onMessage(Message message) {
    try {// w  ww . j av a  2  s.c  o  m
        TextMessage textMessage = (TextMessage) message;
        String json = textMessage.getText();
        PasswordHistory passwordHistory = (PasswordHistory) jsonConverter.getClassFromJson(json,
                PasswordHistory.class);
        passwordHistory.setPassword(AESUtil.getAESDescription(passwordHistory.getPassword(),
                SMSGATEWAY.KEYVALUE, SMSGATEWAY.AES_ALGO));
        if (Objects.equals(passwordHistory.getEmailNotification(),
                SMSGATEWAY.EMAIL_NOTIFICATION_NOT_YET_SEND)) {
            VelocityTempalteModel vtm = new VelocityTempalteModel();
            List<String> toSend = new ArrayList<>();
            List<String> toSentCC = new ArrayList<String>();
            vtm.setFrom(ownerEmail);
            toSend.add(passwordHistory.getEmailAddress());
            vtm.setTo(toSend.toArray(new String[toSend.size()]));
            vtm.setCc(toSentCC.toArray(new String[toSentCC.size()]));
            vtm.setBcc(toSentCC.toArray(new String[toSentCC.size()]));
            vtm.setSubject("User Notification");
            Map maptoSend = new HashMap();
            if (passwordHistory.getLocalId().equals("en")) {
                vtm.setTemplatePath("email_user_confirmation_en.vm");
                //                    if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_UPDATE)) {
                //                        maptoSend.put("headerInfo", "Your password in OPTIMA HR has been updated. <br/>");
                //                    }
                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_NEW)) {
                    maptoSend.put("headerInfo", "Your account in OPTIMA HR already created.<br/>");
                }

                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_RESET)) {
                    maptoSend.put("headerInfo", "Your Password in OPTIMA HR has been reset. <br/>");
                }
            }
            System.out.println(" suksesss");
            if (passwordHistory.getLocalId().equals("in")) {
                vtm.setTemplatePath("email_user_confirmation.vm");
                //                    if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_UPDATE)) {
                //                        maptoSend.put("headerInfo", "Password Anda pada Aplikasi OPTIMA HR berhasil diubah. <br/>");
                //                    }
                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_NEW)) {
                    maptoSend.put("headerInfo", "Anda telah terdaftar di Aplikasi OPTIMA HR <br/>");
                }

                if (passwordHistory.getRequestType().equalsIgnoreCase(SMSGATEWAY.USER_RESET)) {
                    maptoSend.put("headerInfo",
                            "Password Anda pada Aplikasi OPTIMA HR berhasil direset. <br/>");
                }
            }
            Gson gson = new GsonBuilder().create();
            TypeToken<List<String>> token = new TypeToken<List<String>>() {
            };
            List<String> dataRole = gson.fromJson(passwordHistory.getListRole(), token.getType());
            maptoSend.put("role", dataRole);
            maptoSend.put("user", passwordHistory);
            maptoSend.put("ownerAdministrator", ownerAdministrator);
            maptoSend.put("ownerCompany", ownerCompany);
            maptoSend.put("applicationUrl", applicationUrl);
            maptoSend.put("applicationName", applicationName);
            try {
                velocityTemplateSender.sendMail(vtm, maptoSend);
            } catch (Exception ex) {
                LOGGER.error("Error", ex);
            }
            passwordHistory.setEmailNotification(1);
            passwordHistory.setPassword(HashingUtils.getHashSHA256(passwordHistory.getPassword()));
            this.passwordHistoryDao.update(passwordHistory);
            System.out.println(" suksesss");
        }
    } catch (Exception ex) {
        LOGGER.error("Error", ex);
    }
}

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 save(ProscessToApprove entity) throws Exception {
    this.proscessToApproveDao.save(entity);
}

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

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
public SchedulerConfig getEntiyByPK(Long id) throws Exception {
    return this.schedulerConfigDao.getEntiyByPK(id);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void save(ModemDefinition entity) throws Exception {
    long totalDuplicate = this.modemDefinitionDao.getTotalByModemId(entity.getModemId());
    if (totalDuplicate > 0) {
        throw new BussinessException("Data dengan modem id :" + entity.getModemId()
                + " telah ada di database. Silahkan pilih modem id yang lain");
    }//  ww  w . ja va2  s.c o  m
    entity.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(9)));
    //        entity.setCreatedBy(UserInfoUtil.getUserName());
    entity.setCreatedBy("System");
    entity.setCreatedOn(new Date());
    this.modemDefinitionDao.save(entity);
}

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

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
public SystemLetterReference getEntiyByPK(Long id) throws Exception {
    return systemLetterReferenceDao.getEntiyByPK(id);
}

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

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
public Long getTotalByParam(BioRelasiPerusahaanSearchParameter searchParameter) throws Exception {
    return bioRelasiPerusahaanDao.getTotalByParam(searchParameter);
}

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 update(HrmRole entity) throws Exception {
    HrmRole hrmRole = this.hrmRoleDao.getEntiyByPK(entity.getId());
    hrmRole.setUpdatedBy(entity.getUpdatedBy());
    hrmRole.setUpdatedOn(entity.getUpdatedOn());
    hrmRole.setDescription(entity.getDescription());
    hrmRole.setRoleName(entity.getRoleName());
    this.hrmRoleDao.update(hrmRole);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void update(PasswordComplexity entity) throws Exception {
    PasswordComplexity passwordComplexity = this.passwordComplexityDao.getByCode(entity.getCode());
    passwordComplexity.setEmailNotification(entity.getEmailNotification());
    passwordComplexity.setExpiredPeriod(entity.getExpiredPeriod());
    passwordComplexity.setHasLowerCase(entity.getHasLowerCase());
    passwordComplexity.setHasNumber(entity.getHasNumber());
    passwordComplexity.setHasSpecialCharacter(entity.getHasSpecialCharacter());
    passwordComplexity.setHasUpperCase(entity.getHasUpperCase());
    passwordComplexity.setMaxCharacter(entity.getMaxCharacter());
    passwordComplexity.setMinCharacter(entity.getMinCharacter());
    passwordComplexity.setNotificationPeriod(entity.getNotificationPeriod());
    passwordComplexity.setPasswordMustDifferent(entity.getPasswordMustDifferent());
    passwordComplexity.setSmsNotification(entity.getSmsNotification());
    passwordComplexity.setUpdatedBy(entity.getUpdatedBy());
    passwordComplexity.setUpdatedOn(entity.getUpdatedOn());
    this.passwordComplexityDao.update(passwordComplexity);
}

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 update(ProscessToApprove entity) throws Exception {
    ProscessToApprove proscessToApprove = this.proscessToApproveDao.getEntiyByPK(entity.getId());
    proscessToApprove.setUpdatedBy(entity.getUpdatedBy());
    proscessToApprove.setUpdatedOn(entity.getUpdatedOn());
    proscessToApprove.setDescription(entity.getDescription());
    proscessToApprove.setCode(entity.getCode());
    this.proscessToApproveDao.update(proscessToApprove);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void save(TaskDefinition entity) throws Exception {
    System.out.println(" User " + UserInfoUtil.getUserName());
    entity.setModemDefinition(modemDefinitionDao.getEntiyByPK(entity.getModemDefinition().getId()));
    entity.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12)));
    entity.setCreatedBy(UserInfoUtil.getUserName());
    entity.setCretedOn(new Date());
    entity.setSendingCount(0);/*from w w w  . java  2 s .  c om*/
    this.taskDefinitionDao.save(entity);
}