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.hrm.service.impl.TempJadwalKaryawanServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void diverted(long approvalActivityId) throws Exception {
    Map<String, Object> result = super.divertedAndCheckNextApproval(approvalActivityId);
    ApprovalActivity appActivity = (ApprovalActivity) result.get("approvalActivity");
    if (StringUtils.equals((String) result.get("isEndOfApprovalProcess"), "true")) {
        /**//from   w w  w  .  jav a 2s  .  co m
         * kalau status akhir sudah di approved dan tidak ada next approval,
         * berarti langsung insert ke database
         */
        String pendingData = appActivity.getPendingData();
        JsonObject jsonObject = (JsonObject) jsonConverter.getClassFromJson(pendingData, JsonObject.class);
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm");
        Date createdOn = dateFormat.parse(jsonObject.get("createDate").getAsString());
        List<Long> listEmpId = new GsonBuilder().create().fromJson(jsonObject.get("listEmpId").getAsString(),
                new TypeToken<List<Long>>() {
                }.getType());
        this.saveMassPenempatanJadwal(listEmpId, jsonObject.get("groupWorkingId").getAsLong(), createdOn,
                jsonObject.get("createBy").getAsString());
    }

    //if there is no error, then sending the email notification
    sendingApprovalNotification(appActivity);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void updatePhoto(String nik, MultipartFile multipart) throws Exception {
    EmpData empData = empDataDao.getEntityByNik(nik);
    BioData bioData = empData.getBioData();

    //delete old photo (if any)
    if (bioData.getPathFoto() != null) {
        File oldFile = new File(bioData.getPathFoto());
        FileUtils.deleteQuietly(oldFile);
    }//from   ww w  . j  a  va  2 s . c om

    //save new photo to disk
    String pathPhoto = facesIO.getPathUpload() + bioData.getId() + "_" + multipart.getOriginalFilename();

    File file = new File(pathPhoto);
    multipart.transferTo(file);

    //save new path photo
    bioData.setPathFoto(pathPhoto);
    bioDataDao.update(bioData);

}

From source file:com.netsteadfast.greenstep.base.service.BaseService.java

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public E findByPK(String pk) throws ServiceException, Exception {
    if (pk == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }//from  w w  w.  j  a  va2s.  c  o  m
    return this.getBaseDataAccessObject().findByPK(pk);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void updateSignature(String nik, MultipartFile signatureFile) throws Exception {
    EmpData empData = empDataDao.getEntityByNik(nik);
    BioData bioData = empData.getBioData();

    //delete old signature (if any)
    if (bioData.getPathSignature() != null) {
        File oldFile = new File(bioData.getPathSignature());
        FileUtils.deleteQuietly(oldFile);
    }/*from w  w  w .j  a  va 2 s .c o m*/

    //save new signature to disk
    String pathSignature = facesIO.getPathUpload() + bioData.getId() + "_"
            + signatureFile.getOriginalFilename();
    File file = new File(pathSignature);
    signatureFile.transferTo(file);

    //save new path signature
    bioData.setPathSignature(pathSignature);
    bioDataDao.update(bioData);

}

From source file:com.netsteadfast.greenstep.base.service.BaseService.java

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public int countByPK(String pk) throws ServiceException, Exception {
    if (pk == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }/*from   w  w  w.java  2 s .co  m*/
    return this.getBaseDataAccessObject().countByPK(pk);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void rejected(long approvalActivityId, String comment) throws Exception {
    Map<String, Object> result = super.rejectedAndCheckNextApproval(approvalActivityId, comment);
    ApprovalActivity appActivity = (ApprovalActivity) result.get("approvalActivity");

    if (StringUtils.equals((String) result.get("isEndOfApprovalProcess"), "true")) {
        /**//from w w  w.j a  va 2  s . co m
         * kalau status akhir sudah di reject dan tidak ada next approval,
         * berarti langsung insert ke database
         */
        LoanNewApplication entity = this.convertJsonToEntity(appActivity.getPendingData());
        entity.setLoanStatus(HRMConstant.LOAN_REJECTED); //set rejected application status
        entity.setApprovalActivityNumber(appActivity.getActivityNumber()); //set approval activity number, for history approval purpose

        /**
         * saving to DB
         */
        this.save(entity, Boolean.TRUE, null);
    }

    //if there is no error, then sending the email notification
    sendingApprovalNotification(appActivity);
}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void updateFingerPrint(String nik, MultipartFile fingerPrintFile) throws Exception {
    EmpData empData = empDataDao.getEntityByNik(nik);
    BioData bioData = empData.getBioData();

    //delete old fingerPrint (if any)
    if (bioData.getPathFinger() != null) {
        File oldFile = new File(bioData.getPathFinger());
        FileUtils.deleteQuietly(oldFile);
    }//from ww w.  j  a v  a 2s  . c  o  m

    //save new fingerPrint to disk
    String pathFingerPrint = facesIO.getPathUpload() + bioData.getId() + "_"
            + fingerPrintFile.getOriginalFilename();
    File file = new File(pathFingerPrint);
    fingerPrintFile.transferTo(file);

    //save new path fingerPrint
    bioData.setPathFinger(pathFingerPrint);
    bioDataDao.update(bioData);

}

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

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void diverted(long approvalActivityId) throws Exception {
    Map<String, Object> result = super.divertedAndCheckNextApproval(approvalActivityId);
    ApprovalActivity appActivity = (ApprovalActivity) result.get("approvalActivity");
    if (StringUtils.equals((String) result.get("isEndOfApprovalProcess"), "true")) {
        /**//from   w w w. j  a va 2s. com
         * kalau status akhir sudah di approved dan tidak ada next approval,
         * berarti langsung insert ke database
         */
        Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create();
        String pendingData = appActivity.getPendingData();
        LoanNewApplication loan = gson.fromJson(pendingData, LoanNewApplication.class);
        loan.setApprovalActivityNumber(appActivity.getActivityNumber()); //set approval activity number, for history approval purpose

        this.save(loan, Boolean.TRUE, null);
    }

    //if there is no error, then sending the email notification
    sendingApprovalNotification(appActivity);
}

From source file:com.netsteadfast.greenstep.base.service.BaseService.java

@SuppressWarnings("rawtypes")
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public E findByPK(E entityObject) throws ServiceException, Exception {
    if (entityObject == null || !(entityObject instanceof BaseEntity)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }/* ww w .  j  ava  2  s  .c o  m*/
    Map<String, Object> pkMap = BaseEntityUtil.getPKParameter((BaseEntity) entityObject);
    if (pkMap == null || pkMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_INCORRECT));
    }
    return this.getBaseDataAccessObject().findByPK(pkMap);
}

From source file:com.netsteadfast.greenstep.base.service.BaseService.java

@SuppressWarnings("rawtypes")
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public int countByPK(E entityObject) throws ServiceException, Exception {
    if (entityObject == null || !(entityObject instanceof BaseEntity)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }//  w w w.j a v  a2  s .  c  o m
    Map<String, Object> pkMap = BaseEntityUtil.getPKParameter((BaseEntity) entityObject);
    if (pkMap == null || pkMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_INCORRECT));
    }
    return this.getBaseDataAccessObject().countByPK(pkMap);
}