Java 类org.springframework.transaction.annotation.Isolation 实例源码

项目:TITAN    文件:UploadData.java   
/**
 * 执行数据上报
 * 
 * @author gaoxianglong
 * @throws Exception
 */
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.DEFAULT)
public void upload(String taskId, Map<String, CountDownLatch> countDownLatchMap,
        Map<String, List<ResultBean>> resultMap) throws Exception {
    CountDownLatch latch = countDownLatchMap.get(taskId);
    try {
        /* 等待指定场景的压测数据 */
        latch.await();
        List<ResultBean> results = resultMap.get(taskId);
        /* 统计压测结果 */
        ReportPO reportPO = ResultStatistics.result(results);
        if (null != reportPO) {
            /* 新增压测结果信息 */
            reportDao.insertReport(reportPO);
            /* 更改场景状态为未开始 */
            reportDao.updateScene(reportPO.getSceneId(), 0);
            log.info("senceId为[" + reportPO.getSceneId() + "]的压测结果已经收集完成并成功上报");
        }
    } finally {
        /* 资源回收 */
        countDownLatchMap.remove(taskId);
        resultMap.remove(taskId);
    }
}
项目:jsf-core    文件:JsfDeployManagerImpl.java   
@Override
@Transactional(value = "transactionManager", isolation = Isolation.READ_COMMITTED, readOnly = false)
public List<Server> onlineByDeploy(Integer appId, String appInsId, int pid, Date date) throws Exception {
    //用appId和appInsId查找server列表, 不用pid,为了减少时间,避开注册中心的berkeley异步注册时间
    List<Server> servers = serverDao.getServersByApp(appId, appInsId, null);
    if (servers != null && !servers.isEmpty()) {
        List<Integer> serverIds = new ArrayList<Integer>();
        List<Integer> ifaceIds = new ArrayList<Integer>();
        List<IfaceServer> ifaceServerList = new ArrayList<IfaceServer>();
        for (Server server : servers) {
            ifaceIds.add(server.getInterfaceId());
            serverIds.add(server.getId());
            ifaceServerList.add(getIfaceServer(server));
        }
        logger.info("deploy.online.serverIds: {}", serverIds);
        serverDao.updateServerToOnline(serverIds);
        interfaceDataVersionDao.update(ifaceIds, date);
        logger.info("online ifaceAlias list:" + aliasVersionService.updateByServerList(ifaceServerList, date));
        List<IfaceServer> relaAliasServerList = aliasVersionService.getRelaIfaceServerList(ifaceServerList);
        logger.info("自动部署调用: 上线服务端成功, appId:{}, appInsId:{}, serverIds: {}", appId, appInsId, serverIds.toString());
        mergeServers(servers, relaAliasServerList);
        return servers;
    }
    return null;
}
项目:jsf-core    文件:JsfDeployManagerImpl.java   
@Override
@Transactional(value = "transactionManager", isolation = Isolation.READ_COMMITTED, readOnly = false)
public List<Server> offlineByDeploy(Integer appId, String appInsId, int pid, Date date) throws Exception {
    List<Server> servers = serverDao.getServersByApp(appId, appInsId, pid);
    if (servers != null && !servers.isEmpty()) {
        List<Integer> serverIds = new ArrayList<Integer>();
        List<Integer> ifaceIds = new ArrayList<Integer>();
        List<IfaceServer> ifaceServerList = new ArrayList<IfaceServer>();
        for (Server server : servers) {
            ifaceIds.add(server.getInterfaceId());
            serverIds.add(server.getId());
            ifaceServerList.add(getIfaceServer(server));
        }
        logger.info("deploy.offline.serverIds: {}", serverIds);
        serverDao.updateServerToOffline(serverIds);
        interfaceDataVersionDao.update(ifaceIds, date);
        logger.info("offline ifaceAlias list:" + aliasVersionService.updateByServerList(ifaceServerList, date));
        List<IfaceServer> relaAliasServerList = aliasVersionService.getRelaIfaceServerList(ifaceServerList);
        logger.info("自动部署调用: 下线服务端成功, appId:{}, appInsId:{}, serverIds: {}", appId, appInsId, serverIds.toString());
        mergeServers(servers, relaAliasServerList);
        return servers;
    }
    return null;
}
项目:luckyBlog    文件:InfoSer.java   
@Transactional(isolation = Isolation.READ_COMMITTED)
public int modifyPw(String oldPass, String newPass) {
    int result;
    if (checkPass(oldPass)) {
        try {
            infoMapper.updataPass(newPass);
            result = MODIFYPASSSUC;
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
            result = SySTEMERROE;
        }
    } else {
        result = PASSERROE;
    }
    return result;
}
项目:jcalaBlog    文件:InfoSerImpl.java   
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public int modifyPw(String oldPass,String newPass) {
    int result;
   if (checkPass(oldPass)){
       try {
           infoMapper.updataPass(newPass);
           result=MODIFYPASSSUC;
       } catch (Exception e) {
           LOGGER.error(e.getMessage());
           result=SySTEMERROE;
       }
   }else {
       result=PASSERROE;
   }
    return result;
}
项目:ZombieLib2    文件:SequenceService.java   
@Transactional(propagation = MANDATORY, isolation = Isolation.SERIALIZABLE)
public Sequence mergeSequences(List<Sequence> sequences) {
    Sequence main = sequences.get(0);
    if (sequences.size() != 1) {
        sequences.forEach(s -> entityManager.refresh(s));
        List<BookSequence> bookSequences = sequences.stream().
                flatMap(s -> s.getBookSequences().stream()).collect(Collectors.toList());
        bookSequences.forEach(bs -> bs.setSequence(main));
        main.setBookSequences(bookSequences);
        sequenceRepository.save(main);
        sequences.stream().skip(1).forEach(s -> {
            s.setBookSequences(new ArrayList<>());
            sequenceRepository.delete(s);
        });

    }
    return main;
}
项目:dhis2-core    文件:DefaultInterpretationService.java   
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean likeInterpretation( int id )
{
    Interpretation interpretation = getInterpretation( id );

    if ( interpretation == null )
    {
        return false;
    }

    User user = currentUserService.getCurrentUser();

    if ( user == null )
    {
        return false;
    }

    return interpretation.like( user );
}
项目:dhis2-core    文件:DefaultInterpretationService.java   
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean unlikeInterpretation( int id )
{
    Interpretation interpretation = getInterpretation( id );

    if ( interpretation == null )
    {
        return false;
    }

    User user = currentUserService.getCurrentUser();

    if ( user == null )
    {
        return false;
    }

    return interpretation.unlike( user );
}
项目:bamboobsc    文件:SimpleService.java   
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
        propagation=Propagation.REQUIRES_NEW, 
        isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
public DefaultResult<E> findEntityByOid(E object) throws ServiceException, Exception {      
    if (object==null || !(object instanceof BaseEntity) ) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<E> result=new DefaultResult<E>();
    try {           
        E entityObject=this.findByOid(object);  
        if (entityObject!=null && !StringUtils.isBlank( ((BaseEntity<String>)entityObject).getOid() ) ) {
            result.setValue(entityObject);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (result.getValue() == null) {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
项目:elpaaso-core    文件:ManagePaasUserImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackForClassName = { "BusinessException" })
public void deletePaasUser(int paasUserId) throws BusinessException {
       log.debug("find user");
    PaasUser paasUser = paasUserRepository.findOne(paasUserId);
    if (paasUser == null) {
        String message = "PaasUser[" + paasUserId + "] does not exist";
        log.error(message);
        throw new PaasUserNotFoundException(message);
    }
       log.debug("find user envs");
    if (environmentRepository.countActiveByOwner(paasUser) > 0) {
        throw new BusinessException("You cannot delete user id=" + paasUserId + " until active environments exists");
    }
       List<Environment> userRemovedEnvs = environmentRepository.findAllByOwner(paasUser);
       environmentRepository.delete(userRemovedEnvs);
    paasUserRepository.delete(paasUser);
}
项目:elpaaso-core    文件:HsqlDbUtils.java   
/**
 * make an hsql database snapshot (txt file)
 * SCRIPT native query is used
 *    doc : http://www.hsqldb.org/doc/2.0/guide/management-chapt.html#N144AE
 * @param deleteIfExists
 * @return
 * @throws Exception
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public DbSnapshot makeDatabaseSnapshot(boolean deleteIfExists) throws Exception {
    File snapshotfile = new File(giveMeSnapshotName());
    if (snapshotfile.exists() && deleteIfExists) {
        snapshotfile.delete();
    }
    if (snapshotfile.exists()) {
        throw new Exception("unable to snapshot : file already exists " + snapshotfile.getAbsolutePath());
    }
    // String exportFileAbsolutePath = snapshotfile.getAbsolutePath();
    // String hsqldbExport = "SCRIPT " + exportFileAbsolutePath.replaceAll("\\\\","/");
    String hsqldbExport = "SCRIPT '" + snapshotfile.getName() + "'";
    logger.info("export query :{}", hsqldbExport);
    Query nativeQuery = em.createNativeQuery(hsqldbExport);
    nativeQuery.executeUpdate();
    return new DbSnapshot(snapshotfile);
}
项目:bamboobsc    文件:BaseService.java   
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
@SuppressWarnings("unchecked")
public int countByUK(T object) throws ServiceException, Exception {
    if (object==null || !(object instanceof BaseValueObj) ) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    int count=0;
    Class<E> entityObjectClass=GenericsUtils.getSuperClassGenricType(getClass(), 1);
    E entityObject=entityObjectClass.newInstance(); 
    try {
        this.doMapper(object, entityObject, this.getMapperIdVo2Po());
        count=this.getBaseDataAccessObject().countByUK(entityObject);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return count;
}
项目:elpaaso-core    文件:ManageEnvironmentImpl.java   
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public Environment update(EnvironmentDetailsDto environmentDetailsDto) {
    try {
        MDC.put(LOG_KEY_ENVUID, environmentDetailsDto.getUid());
        MDC.put(LOG_KEY_ENVNAME, environmentDetailsDto.getLabel());
        log.debug("updateEnvironment: uid={}", new Object[]{environmentDetailsDto.getUid()});
        Environment environment = environmentRepository.findByUid(environmentDetailsDto.getUid());
        assertHasWritePermissionFor(environment);
        environment.setComment(environmentDetailsDto.getComment());
        return environment;
    } finally {
        MDC.remove(LOG_KEY_ENVNAME);
        MDC.remove(LOG_KEY_ENVUID);
    }
}
项目:elpaaso-core    文件:ManageEnvironmentImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void deleteEnvironment(String uid) throws EnvironmentNotFoundException {
    try {
        MDC.put(LOG_KEY_ENVUID, uid);
        log.debug("deleteEnvironment: uid={}", new Object[]{uid});
        Environment environment = environmentRepository.findByUid(uid);
        assertHasWritePermissionFor(environment);
        MDC.put(LOG_KEY_ENVNAME, environment.getLabel());
        if (environment.isRemoved() || environment.isRemoving()) {
            log.info("Environment '" + environment.getUID() + "' is already deleted or deletion is in progress (ignoring call)");
        } else {
            managePaasActivation.delete(environment.getTechnicalDeploymentInstance().getId());
            // TODO status should be set by managePaasActivation
            environment.setStatus(EnvironmentStatus.REMOVING);
        }
    } finally {
        MDC.remove(LOG_KEY_ENVNAME);
        MDC.remove(LOG_KEY_ENVUID);
    }
}
项目:bamboobsc    文件:BaseService.java   
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
        propagation=Propagation.REQUIRES_NEW, 
        isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)  
public List<T> findListVOByParams(Map<String, Object> params) throws ServiceException, Exception {

    List<T> returnList = null;
    List<E> searchList = findListByParams(params, null);
    if (searchList==null || searchList.size()<1) {
        return returnList;
    }
    returnList=new ArrayList<T>();
    for (E entity : searchList) {
        Class<T> objectClass=GenericsUtils.getSuperClassGenricType(getClass(), 0);
        T obj=objectClass.newInstance();    
        this.doMapper(entity, obj, this.getMapperIdPo2Vo());
        returnList.add(obj);
    }
    return returnList;
}
项目:bamboobsc    文件:BaseService.java   
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
@SuppressWarnings("unchecked")
public int countByUK(T object) throws ServiceException, Exception {
    if (object==null || !(object instanceof BaseValueObj) ) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    int count=0;
    Class<E> entityObjectClass=GenericsUtils.getSuperClassGenricType(getClass(), 1);
    E entityObject=entityObjectClass.newInstance(); 
    try {
        this.doMapper(object, entityObject, this.getMapperIdVo2Po());
        count=this.getBaseDataAccessObject().countByUK(entityObject);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return count;
}
项目:elpaaso-core    文件:ManagePaasUserImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackForClassName = { "BusinessException" })
public void updatePaasUser(PaasUser paasUser) throws ObjectNotFoundException {
    PaasUser persisted = paasUserRepository.findOne(paasUser.getId());
    if (persisted == null) {
        String message = "PaasUser[" + paasUser.getFullName() + "] does not exist";
        log.error(message);
        throw new PaasUserNotFoundException(message);
    }
    persisted.setFirstName(paasUser.getFirstName());
    persisted.setLastName(paasUser.getLastName());
    persisted.setMail(paasUser.getMail());
    persisted.setPhone(paasUser.getPhone());
    persisted.setSsoId(paasUser.getSsoId());
    persisted.setMail(paasUser.getMail());
    // Flush to get potential exception
    // TODO
    // paasUserRepository.flush();
}
项目:omr    文件:PedValidacaoHibernateDAO.java   
@Transactional(isolation=Isolation.READ_UNCOMMITTED,readOnly=true)
public Long countListaPedidosValidacaoCliente(PesquisaPedidoValidacao pesquisaPedidoValidacao) {

    StringBuffer buffer = new StringBuffer();

    buffer.append("Select count(p) from PedValidacaoVO p where p.clienteFk.idCliente = :idCliente ");

    // verifica se � necess�rio pesquisar por data
    if(pesquisaPedidoValidacao.getDataInicioSolicitacao() != null && pesquisaPedidoValidacao.getDataFimSolicitacao() != null) {
        buffer.append("and p.dataSolicitacao between :dataInicio and :dataFim ");
    }

    Query query = getEntityManager().createQuery(buffer.toString());

    query.setParameter("idCliente", pesquisaPedidoValidacao.getPedidoValidacao().getClienteFk().getIdCliente());

    // verifica se � necess�rio pesquisar por data
    if(pesquisaPedidoValidacao.getDataInicioSolicitacao() != null && pesquisaPedidoValidacao.getDataFimSolicitacao() != null) {
        query.setParameter("dataInicio", pesquisaPedidoValidacao.getDataInicioSolicitacao());
        query.setParameter("dataFim", pesquisaPedidoValidacao.getDataFimSolicitacao());
    }

    return (Long)query.getSingleResult();
}
项目:elpaaso-core    文件:ManagePaasUserImpl.java   
/**
 * Try to find the pUsr before persist in Database to avoid Constraints
 * Violation Exception
 * 
 * @param pUsr
 */
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackForClassName = { "BusinessException" })
public void checkBeforeCreatePaasUser(PaasUser pUsr) {
    try {
        PaasUser user = findPaasUser(pUsr.getSsoId().getValue());
        // Update information
        user.setFirstName(pUsr.getFirstName());
        user.setLastName(pUsr.getLastName());
        user.setMail(pUsr.getMail());
        user.setPaasUserRole(pUsr.getPaasUserRole());
        user.setSubTenant(pUsr.getSubTenant());
        log.debug("PaasUser " + pUsr.getSsoId() + " found ==> No need te recreate one, just update informations about it", pUsr.getFullName());
    } catch (ObjectNotFoundException ex) {
        createPaasUser(pUsr);
        log.debug("No paasUser " + pUsr.getSsoId() + " found ==> Create one ", ex.getCause());
        log.debug(findAllPaasUsers().toString());
    }
}
项目:elpaaso-core    文件:ManageTechnicalDeploymentImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public String findTechnicalDeployment(int technicalDeploymentId)
        throws ObjectNotFoundException, TechnicalException {
    TechnicalDeployment technicalDeployment = find(technicalDeploymentId);

    try {
        JAXBContext jc = JAXBContext
                .newInstance(TechnicalDeployment.class);
        Marshaller m = jc.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        StringWriter st = new StringWriter();
        m.marshal(technicalDeployment, st);
        return st.toString();
    } catch (JAXBException e) {
        String message = "Data access error while retrieving TechnicalDeployment["
                + technicalDeploymentId + "]";
        log.error(message, e);
        throw new TechnicalException(message, e);
    }
}
项目:elpaaso-core    文件:ManageLogicalDeploymentImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackForClassName = { "BusinessException" })
public LogicalDeployment checkOverallConsistencyAndUpdateLogicalDeployment(LogicalDeployment logicalDeployment) throws BusinessException {
    // First check logical deployment has been persisted
    LogicalDeployment persisted = logicalDeploymentRepository.findOne(logicalDeployment.getId());
    if (persisted == null) {
        String message = "LogicalDeployment[" + logicalDeployment.getName() + "] does not exist";
        log.error(message);
        throw new ObjectNotFoundException(message);
    }

    // check consistency and update any model element which might be
    // generated/modified during check
    // typically resolved maven references are updated on execution nodes
    // and logical services
    checkOverallConsistency(logicalDeployment, true);

    // if no error, then persist our updates
    return logicalDeploymentRepository.save(logicalDeployment);
}
项目:elpaaso-core    文件:ManageLogicalDeploymentImpl.java   
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public LogicalDeployment findLogicalDeployment(int logicalDeploymentId) throws ObjectNotFoundException {
    LogicalDeployment logicalDeployment = logicalDeploymentRepository.findOne(logicalDeploymentId);
    if (logicalDeployment == null) {
        String message = "LogicalDeployment[" + logicalDeploymentId + "] does not exist";
        log.error(message);
        throw new ObjectNotFoundException(message);
    }
    // TODO verifier strategie de loading des logicalServices et
    // processingNodes pour forcer le chargement des LogicalServices
    logicalDeployment.listProcessingNodes().size();
    logicalDeployment.listLogicalServices().size();
    for (LogicalService logicalService : logicalDeployment.listLogicalServices()) {
        logicalService.listLogicalServicesAssociations().size();
    }
    // pour forcer le chargement des NodeClusters
    // logicalDeployment.listNodeClusters().size();
    for (ProcessingNode jeeProcessing : logicalDeployment.listProcessingNodes()) {
        jeeProcessing.listLogicalServicesAssociations().size();
    }
    // retourne un logical deployment contenant des logicalServices et
    // processingNodes charges
    return logicalDeployment;
}
项目:TITAN    文件:SceneServiceImpl.java   
/**
 * @desc 删除场景并更新相关连数据
 *
 * @author liuliang
 *
 * @param sceneId
 * @return
 */
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.DEFAULT, timeout = 5)
public int removeSceneAndUpdateRelatedData(long sceneId) throws Exception {
    //1、删场景
    int result = sceneDao.removeScene(String.valueOf(sceneId));
    //2、删定时任务
    automaticTaskDao.delBySceneId(sceneId);
    //3、删监控集
    monitorSetDao.delBySceneId(sceneId);
    return result;
}
项目:TITAN    文件:LinkServiceImpl.java   
/**
 * @desc 删除链路并更新链路相关的场景
 *
 * @author liuliang
 *
 * @param linkId 链路ID
 * @param sceneCount 包含该链路ID的场景数
 * @return int 受影响的记录数
 * @throws Exception
 */
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.DEFAULT, timeout = 5)
public int removeLinkAndUpdateScene(long linkId, int sceneCount) throws Exception {
    //1、删除链路
    int removedLinkNum = linkDao.removeLink(String.valueOf(linkId));
    //2、更新链路相关场景
    //2.1、查询linkId关联的所有场景
    List<Scene> sceneList = sceneDao.getSceneListByLinkId(linkId, 0, sceneCount);  
    //2.2、逐条处理
    if((null != sceneList) && (0 < sceneList.size())){
        String containLinkid = "";
        String linkRelation = "";
        for(Scene scene:sceneList){
            containLinkid = scene.getContainLinkid();
            linkRelation = scene.getLinkRelation();
            if(containLinkid.equals(String.valueOf(linkId))){
                //2.2.1、该场景只包含待删除的一个链路,直接删除场景
                sceneDao.removeScene(String.valueOf(scene.getSceneId()));
            }else{
                //2.2.2、该场景包含多个链路,更新场景
                //a、数据处理
                containLinkid = this.replaceLinkId(linkId, containLinkid);
                linkRelation = this.replaceLinkId(linkId, linkRelation);
                //b、更新
                scene.setContainLinkid(containLinkid);
                scene.setLinkRelation(linkRelation);
                sceneDao.updateScene(scene);
            }
        }
    }
    //3、返回处理结果
    return removedLinkNum;
}
项目:hibatis    文件:Service1.java   
@Transactional(propagation = Propagation.REQUIRED , isolation = Isolation.READ_UNCOMMITTED)
public void insert(){
    System.out.println(TransactionSynchronizationManager.getCurrentTransactionIsolationLevel());
    System.out.println(">>>>>" + TransactionCacheContextHolder.getContext());
    Test test = new Test();
    test.setA(new Random().nextInt());
    sqlMapper.insert(test);
    service2.insert();
    throw new RuntimeException();
}
项目:hibatis    文件:Service2.java   
@Transactional(propagation = Propagation.NOT_SUPPORTED , isolation = Isolation.READ_UNCOMMITTED )
public void insert(){
    System.out.println(TransactionSynchronizationManager.getCurrentTransactionIsolationLevel());
    System.out.println(">>>>>" + TransactionCacheContextHolder.getContext());
    Test test = new Test();
    test.setA(new Random().nextInt());
    sqlMapper.insert(test);
}
项目:springboot-start    文件:MutiJpaTest.java   
@Test
    @Transactional(value = "primaryTransactionManager", isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public void test() throws Exception {

//        userRepository.save(new User("aaa", 10));
//        userRepository.save(new User("bbb", 20));
//        userRepository.save(new User("ccc", 30));
//        userRepository.save(new User("ddd", 40));
//        userRepository.save(new User("eee", 50));
//
//        Assert.assertEquals(5, Lists.newArrayList(userRepository.findAll()).size());
//
//        memberRepository.save(new Member("o1", 1));
//        memberRepository.save(new Member("o2", 2));
//        memberRepository.save(new Member("o3", 2));
//
//        Assert.assertEquals(3, Lists.newArrayList(memberRepository.findAll()).size());

        User u1 = userRepository.findByName("xiaofeng");
        System.out.println("第一次查询:" + u1.getAge());

        User u2 = userRepository.findByName("xiaofeng");
        System.out.println("第二次查询:" + u2.getAge());

        u1.setAge(20);
        userRepository.save(u1);
        User u3 = userRepository.findByName("xiaofeng");
        System.out.println("第三次查询:" + u3.getAge());


    }
项目:jsf-core    文件:ServerAliasManagerImpl.java   
@Override
@Transactional(value = "transactionManager", isolation = Isolation.READ_COMMITTED, readOnly = false)
public void dynamicGrouping(List<ServerAlias> newServerAliasList,
                            List<Integer> cancelServerAliasList,
                            List<IfaceServer> updateServerVersionList,
                            UserAction action) throws Exception {
    try {
        if (cancelServerAliasList != null && !cancelServerAliasList.isEmpty()) {
            batchCancel(cancelServerAliasList);
        }

        if (newServerAliasList != null && !newServerAliasList.isEmpty()) {
            batchInsert(newServerAliasList);
        }

        if (updateServerVersionList != null && !updateServerVersionList.isEmpty()) {
            aliasVersionService.updateByServerList(updateServerVersionList, new Date());
        }

        action.setIsSucc(1);
    } catch (Exception e) {
        action.setIsSucc(0);
        throw new RuntimeException(e);
    } finally {
        userActionDAO.insert(action);
    }
}
项目:ipayquery    文件:UserRoleServiceImpl.java   
/**
 * 新增用户角色信息
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public void insertRoleData(UserRole userRole) {

    userRoleDao.insertRoleData(userRole);

}
项目:ipayquery    文件:UserRoleServiceImpl.java   
/**
 * 删除角色
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public void deleteRole(String ur_id) {

    userRoleDao.deleteRole(ur_id);

}
项目:ipayquery    文件:UserRoleServiceImpl.java   
/**
 * 通过角色id得到用户帐号
 *
 * @return
 *
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public String getUAccount(String xzrl) {
    String uAccount = userRoleDao.getUAccount(xzrl);
    return uAccount;
}
项目:ipayquery    文件:UserServiceImpl.java   
/**
 * 同步员工信息
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public int syncStaff() {
    userDao.syncUser();
    return 1;
}
项目:ipayquery    文件:UserServiceImpl.java   
/**
 * 删除用户信息
 */
/* @Override */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
public void deleteUser(String u_id) {
    // 删除用户的权限
    userRoleDao.deleteRoleByAccount(u_id);
    // 删除用户
    userDao.deleteUser(u_id);
}
项目:ipayquery    文件:RoleServiceImpl.java   
/**
 * 新增角色信息
 *
 * @param role
 * @return
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public boolean insertRole(Role role) {
    if (StringUtil.notEmpty(roleDao.getRoleIdByIdAndName(role.getSystem_id(), null, role.getR_name()))) {
        return false;
    } else {
        roleDao.insertRole(role);
        return true;
    }
}
项目:ipayquery    文件:RoleServiceImpl.java   
/**
 * 更新角色信息
 *
 * @param role
 * @return
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public String updateRoleBaseInfo(Role role) {

    // 系统标志
    String system_id = role.getSystem_id();
    // 角色ID
    String r_id = role.getR_id();
    // 角色名称
    String r_name = role.getR_name();

    String roleIdById = roleDao.getRoleIdByIdAndName(system_id, r_id, null);
    String roleIdByName = roleDao.getRoleIdByIdAndName(system_id, null, r_name);

    if (StringUtil.isNotEmpty(roleIdById)) {

        if (StringUtil.isEmpty(roleIdByName) || roleIdByName.equals(r_id)) {
            roleDao.updateRoleBaseInfo(role);
            // 更新成功
            return "0";
        } else {
            // 该角色名已存在
            return "1";
        }

    } else {
        // 该角色已被删除
        return "2";
    }
}
项目:ipayquery    文件:RoleServiceImpl.java   
/**
 * 更新角色权限
 *
 * @param role
 * @return
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public boolean updateRoleFunction(Role role) {

    if (roleDao.updateRoleFunction(role) > 0) {
        // 更新成功
        return true;
    } else {
        // 该角色已被删除
        return false;
    }

}
项目:ipayquery    文件:RoleServiceImpl.java   
/**
 * 删除角色信息
 *
 * @param r_id
 * @return
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
/* @Override */
public void deleteRoleById(String r_id) {
    roleDao.deleteRoleById(r_id);

}
项目:jaf-examples    文件:AccountServiceImpl.java   
@Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
    public void transferAmount(String fromUsername, String toUsername, int amount) {
        accountDao.subtractAmount(fromUsername, amount);
//         int i = 5 / 0;   // 模拟抛出异常,测试事务回滚
        accountDao.addAmount(toUsername, amount);

        System.out.println("transfer amount success");
    }
项目:Spring-MVC-Blueprints    文件:InvoiceAddProductImpl.java   
@Transactional(
        propagation = Propagation.REQUIRED,
        isolation = Isolation.DEFAULT
        )
@Override
public void addProduct(InventoryForm invForm) {
    Catalog catalog = new Catalog();
    catalog.setName(invForm.getName());
    catalog.setDescription(invForm.getDescription());
    catalog.setCostPrice(invForm.getCostPrice());
    catalog.setRetailPrice(invForm.getRetailPrice());
    catalog.setWholesalePrice(invForm.getWholeSalePrice());
    catalog.setStock(invForm.getStock());
    catalog.setTags(invForm.getTags());
    catalog.setSupplierId(invForm.getVendor());

    Uom uom = new Uom();
    uom.setId(invForm.getUomId());

    MaterialType type = new MaterialType();
    type.setId(invForm.getTypeId());

    catalog.setUom(uom);
    catalog.setMaterialType(type);

    inventoryDao.setProduct(catalog);

}
项目:c2mon    文件:RuleTagConfigTransactedImpl.java   
@Override
@Transactional(value = "cacheTransactionManager", propagation=Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void doRemoveRuleTag(final Long id, final ConfigurationElementReport elementReport) {
  LOGGER.trace("Removing RuleTag " + id);
  try {
    RuleTag ruleTag = tagCache.get(id);
    Collection<Long> ruleIds = ruleTag.getCopyRuleIds();  
    if (!ruleIds.isEmpty()) {
      LOGGER.debug("Removing rules dependent on RuleTag " + id);
      for (Long ruleId : ruleIds) { //concurrent modifcation as a rule is removed from the list during the remove call!
        if (tagLocationService.isInTagCache(ruleId)) { //may already have been removed if a previous rule in the list was used in this rule!
          ConfigurationElementReport newReport = new ConfigurationElementReport(Action.REMOVE, Entity.RULETAG, ruleId);
          elementReport.addSubReport(newReport);
          ruleTagConfigHandler.removeRuleTag(ruleId, newReport); //call config handler bean so transaction annotation is noticed
        }         
      }                
    }
    tagCache.acquireWriteLockOnKey(id);      
    Collection<Long> ruleInputTagIds = Collections.EMPTY_LIST;
    try {
      ruleInputTagIds = ruleTag.getCopyRuleInputTagIds();                
      Collection<Long> alarmIds = ruleTag.getCopyAlarmIds();                  
      if (!alarmIds.isEmpty()) {
        LOGGER.debug("Removing Alarms dependent on RuleTag " + id);
        for (Long alarmId : alarmIds) { //need copy as modified concurrently by remove alarm
          ConfigurationElementReport alarmReport = new ConfigurationElementReport(Action.REMOVE, Entity.ALARM, alarmId);
          elementReport.addSubReport(alarmReport);
          alarmConfigHandler.removeAlarm(alarmId, alarmReport);
        }        
      }
      for (Long inputTagId : ruleInputTagIds) {
        tagConfigGateway.removeRuleFromTag(inputTagId, id); //allowed to lock tag below the rule...
      }

      for (ConfigurationEventListener listener : configurationEventListeners) {
        listener.onConfigurationEvent(ruleTag, Action.REMOVE);
      }

      configurableDAO.deleteItem(ruleTag.getId());                                           
    }
    catch (RuntimeException rEx) {
      String errMessage = "Exception caught when removing rule tag with id " + id;
      LOGGER.error(errMessage, rEx); 
      throw new UnexpectedRollbackException(errMessage, rEx);   
    } finally {
      if (tagCache.isWriteLockedByCurrentThread(id)) {
        tagCache.releaseWriteLockOnKey(id);
      }        
    }
  } catch (CacheElementNotFoundException e) {
    LOGGER.debug("Attempting to remove a non-existent RuleTag - no action taken.");
    elementReport.setWarning("Attempting to removed a non-existent RuleTag");      
  }       
}