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

@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
@Override//from  w w w.  j a va2s. co m
public TempJadwalKaryawan getEntityByEmpDataIdAndTanggalWaktuKerja(Long id, Date implementationDate)
        throws Exception {
    return tempJadwalKaryawanDao.getEntityByEmpDataIdAndTanggalWaktuKerja(id, implementationDate);
}

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 String saveBiodataRevisionWithApproval(Object modifiedEntity, String dataType, EmpData empData)
        throws Exception {

    //Jika Approval Definition untuk proses revisi biodata belum di buat, lempar BussinessException
    if (isApprovalDefinitionNotFound()) {
        throw new BussinessException("biodata.biodata_revision_doesnt_have_approval_def");

    }//ww  w . java  2  s  .c  o m

    HrmUser requestUser = hrmUserDao.getByEmpDataId(empData.getId());

    //Dapatkan List Pending Approval Activity
    List<ApprovalActivity> listPreviousActivities = approvalActivityDao
            .getPendingRequest(requestUser.getUserId());

    //Filter hanya yang berasal dari proses request revisi biodata
    listPreviousActivities = Lambda.select(listPreviousActivities,
            Lambda.having(Lambda.on(ApprovalActivity.class).getApprovalDefinition().getName(),
                    Matchers.equalTo(HRMConstant.BIO_DATA_EDIT)));

    //Looping satu persatu
    for (ApprovalActivity approvalActivity : listPreviousActivities) {
        String pendingData = approvalActivity.getPendingData();
        Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create();

        // dapatkan nilai dataType (jenis kelompok formulir biodata) dari pending approval activity
        JsonElement jsonElementDataType = gson.fromJson(pendingData, JsonObject.class).get("dataType");
        if (!jsonElementDataType.isJsonNull()) {

            String dataTypeFromJson = jsonElementDataType.getAsString();

            //Jika kelompok formulir dari pending Request sama dengan yang akan di ajukan sekarang, maka lempar BusinessException,
            //karena tidak boleh mengajukan perubahan biodata pada satu jenis kelompok formulir, 
            //jika sebelumnya sudah pernah ada pengajuan revisi pada jenis kelompok formulir tsb dan statusnya masih pending.
            if (StringUtils.equals(dataType, dataTypeFromJson)) {
                throw new BussinessException("biodata.error_revision_same_data_type_which_still_pending_found");
            }

        }

    }

    return this.saveRevision(modifiedEntity, dataType, empData, Boolean.FALSE, null);

}

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

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
public TempJadwalKaryawan getByEmpId(Long id, Date implementationDate) throws Exception {
    return tempJadwalKaryawanDao.getByEmpId(id, implementationDate);
}

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 String saveWithApproval(LoanNewApplication entity) throws Exception {

    String result = isLoanAllowed(entity.getLoanNewType().getId(), entity.getLoanNewSchema().getId(),
            entity.getEmpData(), entity.getNominalPrincipal(), Boolean.FALSE, null);

    if (!StringUtils.equals("yes", result)) {
        throw new BussinessException(result);
    }/*from w w w  .j a v a2s  .  c om*/
    entity.setLoanStatus(HRMConstant.LOAN_UNDISBURSED);//Default status loan undisbursed
    return this.save(entity, Boolean.FALSE, null);
}

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

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 50)
public List<TempJadwalKaryawan> getAllByEmpIdWithDetailWithFromAndUntilPeriod(long empId) throws Exception {
    WtPeriode wtPeriode = wtPeriodeDao.getEntityByAbsentTypeActive();
    return tempJadwalKaryawanDao.getAllByEmpIdWithDetailWithFromAndUntilPeriod(empId,
            wtPeriode.getFromPeriode(), wtPeriode.getUntilPeriode());
}

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 findByPKng(PK pk) throws ServiceException, Exception {
    if (pk == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }/* w w w  .java 2  s  .c  o  m*/
    return this.getBaseDataAccessObject().findByPK((String) pk);
}

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 countByPKng(PK pk) throws ServiceException, Exception {
    if (pk == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }// w  w w.jav  a  2s .  c o  m
    return this.getBaseDataAccessObject().countByPK((String) 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 String saveWithRevised(LoanNewApplication entity, Long approvalActivityId, String activityNumber)
        throws Exception {
    String message = "error";

    String result = isLoanAllowed(entity.getLoanNewType().getId(), entity.getLoanNewSchema().getId(),
            entity.getEmpData(), entity.getNominalPrincipal(), Boolean.TRUE, activityNumber);

    if (!StringUtils.equals("yes", result)) {
        throw new BussinessException(result);
    }//from  w w w .j  a  va  2 s  . com

    /**
     * proceed of revising data
     */
    String pendingData = this.getJsonPendingData(entity);

    this.revised(approvalActivityId, pendingData);

    message = "success_need_approval";
    return message;
}

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

/**
 * map ???select/*from  www  . j  av  a 2  s.  co m*/
 * 
 * map  key persisent obj ???
 * map  value persisent obj ?
 * 
 * likeParams  value  '%test%' 'test%'
 * 
 * @param params
 * @param likeParams
 * @return
 * @throws Exception
 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public long countByParams(Map<String, Object> params, Map<String, String> likeParams)
        throws ServiceException, Exception {

    return this.getBaseDataAccessObject().countByParams(params, likeParams);
}

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 saveMassPenempatanJadwalException(List<EmpData> data, long groupWorkingId, Date startDate,
        Date endDate) throws Exception {
    List<Long> listIdEmp = Lambda.extract(data, Lambda.on(EmpData.class).getId());
    WtGroupWorking groupWorking = wtGroupWorkingDao.getEntiyByPK(groupWorkingId);
    groupWorking.setIsActive(Boolean.TRUE);
    wtGroupWorkingDao.update(groupWorking);

    for (Long empDataId : listIdEmp) {
        EmpData empData = empDataDao.getEntiyByPK(empDataId);
        empData.setWtGroupWorking(wtGroupWorkingDao.getEntiyByPK(groupWorkingId));
        this.empDataDao.update(empData);
    }//  w w  w. j  a  v  a  2  s .co  m

    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm");
    String dataToJson = jsonConverter.getJson(listIdEmp.toArray(new Long[listIdEmp.size()]));
    final JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("listEmpId", dataToJson);
    jsonObject.addProperty("groupWorkingId", groupWorkingId);
    jsonObject.addProperty("createDate", dateFormat.format(new Date()));
    jsonObject.addProperty("createBy", UserInfoUtil.getUserName());
    jsonObject.addProperty("startDate", dateFormat.format(startDate));
    jsonObject.addProperty("endDate", dateFormat.format(endDate));
    jsonObject.addProperty("locale", FacesUtil.getFacesContext().getViewRoot().getLocale().toString());

    this.jmsTemplateMassJadwalKerjaExcection.send(new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(jsonObject.toString());
        }
    });
}