org.springframework.transaction.annotation.Propagation Java Examples

The following examples show how to use org.springframework.transaction.annotation.Propagation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuftragDao.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param posString Format ###.## (<order number>.<position number>).
 */
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public AuftragsPositionDO getAuftragsPosition(final String posString)
{
  Integer auftragsNummer = null;
  Short positionNummer = null;
  if (posString == null) {
    return null;
  }
  final int sep = posString.indexOf('.');
  if (sep <= 0 || sep + 1 >= posString.length()) {
    return null;
  }
  auftragsNummer = NumberHelper.parseInteger(posString.substring(0, posString.indexOf('.')));
  positionNummer = NumberHelper.parseShort(posString.substring(posString.indexOf('.') + 1));
  if (auftragsNummer == null || positionNummer == null) {
    log.info("Cannot parse order number (format ###.## expected: " + posString);
    return null;
  }
  @SuppressWarnings("unchecked")
  final List<AuftragDO> list = getHibernateTemplate().find("from AuftragDO k where k.nummer=?", auftragsNummer);
  if (CollectionUtils.isEmpty(list) == true) {
    return null;
  }
  return list.get(0).getPosition(positionNummer);
}
 
Example #2
Source File: LikeServiceBean.java    From bbs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 根据话题Id查询被点赞数量
 * @param topicId 话题Id
 * @return
 */
@Transactional(readOnly=true, propagation=Propagation.NOT_SUPPORTED)
public Long findLikeCountByTopicId(Long topicId){
	Long count = 0L;
	//表编号
	int tableNumber = topicLikeConfig.topicIdRemainder(topicId);
	Query query  = null;
	
	if(tableNumber == 0){//默认对象
		query = em.createQuery("select count(o) from TopicLike o where o.topicId=?1");
		query.setParameter(1, topicId);
		count = (Long)query.getSingleResult();
		
	}else{//带下划线对象
		query = em.createQuery("select count(o) from TopicLike_"+tableNumber+" o where o.topicId=?1");
		query.setParameter(1, topicId);
		count = (Long)query.getSingleResult();
	}
	return count;
}
 
Example #3
Source File: ModelResource.java    From plumdo-work with Apache License 2.0 6 votes vote down vote up
@PutMapping(value = "/models/{modelId}", name = "模型修改")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ModelResponse updateModel(@PathVariable String modelId, @RequestBody ModelRequest modelRequest) {
    Model model = getModelFromRequest(modelId);
    model.setCategory(modelRequest.getCategory());
    if (!modelRequest.getKey().equals(model.getKey())) {
        checkModelKeyExists(modelRequest.getKey());
        managementService.executeCommand(new UpdateModelKeyCmd(modelId, modelRequest.getKey()));
    }
    model.setKey(modelRequest.getKey());
    model.setName(modelRequest.getName());
    model.setMetaInfo(modelRequest.getMetaInfo());
    model.setTenantId(modelRequest.getTenantId());
    repositoryService.saveModel(model);

    return restResponseFactory.createModelResponse(model);
}
 
Example #4
Source File: FileServiceImpl.java    From efo with MIT License 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
        Exception.class)
public boolean[] updateUrl(int id, String oldLocalUrl, String localUrl, String visitUrl) {
    boolean[] b = new boolean[]{false, false};
    boolean canUpdateLocalUrl = Checker.isExists(oldLocalUrl) && Checker.isNotEmpty(localUrl) && Checker
            .isNotExists(localUrl) && !localUrlExists(localUrl);
    if (canUpdateLocalUrl) {
        FileExecutor.renameTo(oldLocalUrl, localUrl);
        fileDAO.updateLocalUrlById(id, localUrl);
        b[0] = true;
    }
    if (Checker.isNotEmpty(visitUrl) && !visitUrlExists(visitUrl)) {
        fileDAO.updateVisitUrlById(id, visitUrl);
        b[1] = true;
    }
    return b;
}
 
Example #5
Source File: OrganizationLogicServiceImpl.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@ServiceMethodAuthority(type={ServiceMethodType.UPDATE})
@Transactional(
		propagation=Propagation.REQUIRED, 
		readOnly=false,
		rollbackFor={RuntimeException.class, IOException.class, Exception.class} )		
@Override
public DefaultResult<OrganizationVO> update(OrganizationVO organization) throws ServiceException, Exception {
	if (organization==null || super.isBlank(organization.getOid())) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
	}
	this.checkOrganizationIdIsZero(organization);
	OrganizationVO dbOrganization = this.findOrganizationData(organization.getOid());
	organization.setOrgId( dbOrganization.getOrgId() );
	this.setStringValueMaxLength(organization, "description", MAX_DESCRIPTION_LENGTH);
	this.handlerLongitudeAndLatitude(organization);
	return this.getOrganizationService().updateObject(organization);
}
 
Example #6
Source File: SystemFormLogicServiceImpl.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@ServiceMethodAuthority(type={ServiceMethodType.DELETE})
@Transactional(
		propagation=Propagation.REQUIRED, 
		readOnly=false,
		rollbackFor={RuntimeException.class, IOException.class, Exception.class} )			
@Override
public DefaultResult<Boolean> deleteTemplate(SysFormTemplateVO template) throws ServiceException, Exception {
	if ( null == template || super.isBlank(template.getOid()) ) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
	}
	DefaultResult<SysFormTemplateVO> oldResult = this.sysFormTemplateService.findObjectByOid(template);
	if ( oldResult.getValue() == null ) {
		throw new ServiceException( oldResult.getSystemMessage().getValue() );
	}
	Map<String, Object> paramMap = new HashMap<String, Object>();
	paramMap.put("templateId", oldResult.getValue().getTplId());
	if ( this.sysFormService.countByParams(paramMap) > 0 ) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
	}		
	return this.sysFormTemplateService.deleteObject(template);
}
 
Example #7
Source File: TemplateServiceBean.java    From bbs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 根据模板目录名称和布局类型和引用代码查询布局
 * @param dirName 模板目录
 * @param type 布局类型
 * @param referenceCode 模块引用代码
 * @return
 */
@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
public Layout findLayoutByReferenceCode(String dirName,Integer type,String referenceCode){
	Query query = em.createQuery("select o from Layout o where o.dirName=?1 and o.type=?2 and o.referenceCode=?3");
	
	//给SQL语句设置参数
	query.setParameter(1, dirName);
	query.setParameter(2, type);
	query.setParameter(3, referenceCode);
	List<Layout> layoutList = query.getResultList();
	if(layoutList != null && layoutList.size() >0){
		for(Layout layout : layoutList){
			return layout;
		}
	}
	return null;
}
 
Example #8
Source File: ActionIntercepterSupport.java    From tcc-transaction with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public TXContext addAction(String serialNumber,ActionExecutePayload bean)throws Throwable{
    // 新增事务Begin状态
    TransactionInfo transactionInfo = new TransactionInfo();
    transactionInfo.setTxId(TransactionIdGenerator.next());
    transactionInfo.setParentId(Constants.TX_ROOT_ID); // 事务入口
    transactionInfo.setContext(JSON.toJSONString(bean)); // 当前调用上下文环境
    transactionInfo.setBusinessId(serialNumber); // 业务流水号
    transactionInfo.setBusinessType(bean.getBizType()); // 业务类型
    transactionInfo.setModuleId(bean.getModuleId());
    transactionInfo.setTxType(bean.getTxType().getCode()); // TC | TCC
    transactionInfo.setTxStatus(TransactionStatusEnum.BEGIN.getCode()); //begin状态
    transactionInfo.setRetriedCount(JSON.toJSONString(  // 设置重试次数
            new RetryCount(defaultMsgRetryTimes, defaultCancelRetryTimes, defaultConfirmRetryTimes)));
    createTransactionInfo(transactionInfo);
    // 设置事务上下文
    TXContextSupport ctx= new TXContextSupport();
    ctx.setParentId(transactionInfo.getParentId());
    ctx.setTxId(transactionInfo.getTxId());
    ctx.setTxType(transactionInfo.getTxType());
    ctx.setBusinessType(transactionInfo.getBusinessType());
    ctx.setSerialNumber(serialNumber);
    return ctx;
}
 
Example #9
Source File: CompensableSecondaryFilter.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Result createErrorResultForProvider(Throwable throwable, String propagatedBy, boolean attachRequired) {
	CompensableBeanRegistry beanRegistry = CompensableBeanRegistry.getInstance();
	CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory();
	RemoteCoordinator compensableCoordinator = (RemoteCoordinator) beanFactory.getCompensableNativeParticipant();

	RpcResult result = new RpcResult();

	CompensableServiceFilter.InvocationResult wrapped = new CompensableServiceFilter.InvocationResult();
	wrapped.setError(throwable);
	if (attachRequired) {
		wrapped.setVariable(Propagation.class.getName(), propagatedBy);
		wrapped.setVariable(RemoteCoordinator.class.getName(), compensableCoordinator.getIdentifier());
	}

	result.setException(null);
	result.setValue(wrapped);

	return result;
}
 
Example #10
Source File: UserServiceImpl.java    From PedestrianDetectionSystem with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
public int registerUser(String username, String password, String repeat_password, String phonenumber) {

    if (!password.equals(repeat_password)) {
        return 1;
    }
    User user = new User();
    user.setUsername(username);
    user.setPassword(password);
    user.setPhonenumber(phonenumber);
    User user1 = userMapper.selectUser(user);
    if (user1 != null){
        return 2;
    }
    userMapper.insert(user);
    return 0;
}
 
Example #11
Source File: TestBusiness.java    From maven-archetype with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * This method was generated by MyBatis Generator.
 * This method corresponds to the database table test
 *
 * @mbggenerated
 */
@Transactional(propagation=Propagation.REQUIRED,isolation =Isolation.REPEATABLE_READ, rollbackFor = Exception.class)
public int insertSelective(List<Test> list) throws Exception {
    int insertCount = 0;
    if (list == null || list.size() == 0) {
        return insertCount;
    }
    for (Test  obj : list) {
        if (obj == null) {
            continue;
        }
        try {
            insertCount += this.testMapper.insertSelective(obj);
        } catch (Exception e) {
            throw e;
        }
    }
    return insertCount;
}
 
Example #12
Source File: YggdrasilServiceImpl.java    From authlib-agent with MIT License 6 votes vote down vote up
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@Override
public void joinServer(String accessToken, UUID profileUUID, String serverid) throws ForbiddenOperationException {
	Session session = sessionFactory.getCurrentSession();

	Account account = loginService.loginWithToken(accessToken).getAccount();
	GameProfile profile = session.get(GameProfile.class, profileUUID.toString());
	if (profile == null || !account.equals(profile.getOwner())) {
		throw new ForbiddenOperationException(MSG_INVALID_PROFILE);
	}

	if (profile.isBanned()) {
		throw new ForbiddenOperationException(MSG_PROFILE_BANNED);
	}

	serveridRepo.createServerId(serverid, profileUUID);
}
 
Example #13
Source File: GreetingServiceBean.java    From spring-security-fundamentals with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(
        propagation = Propagation.REQUIRED,
        readOnly = false)
@CacheEvict(
        value = "greetings",
        key = "#id")
public void delete(Long id) {
    logger.info("> delete id:{}", id);

    counterService.increment("method.invoked.greetingServiceBean.delete");

    greetingRepository.delete(id);

    logger.info("< delete id:{}", id);
}
 
Example #14
Source File: TemplateDAOJpa.java    From SeaCloudsPlatform with Apache License 2.0 6 votes vote down vote up
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public List<ITemplate> getAll() {

    TypedQuery<ITemplate> query = entityManager.createNamedQuery(
            Template.QUERY_FIND_ALL, ITemplate.class);
    List<ITemplate> templates = new ArrayList<ITemplate>();
    templates = (List<ITemplate>) query.getResultList();
    if (templates != null) {
        logger.debug("Number of templates:" + templates.size());
    } else {
        logger.debug("No Result found.");
    }

    return templates;

}
 
Example #15
Source File: SystemBeanHelpLogicServiceImpl.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@ServiceMethodAuthority(type={ServiceMethodType.INSERT})
@Transactional(
		propagation=Propagation.REQUIRED, 
		readOnly=false,
		rollbackFor={RuntimeException.class, IOException.class, Exception.class} )				
@Override
public DefaultResult<SysBeanHelpExprMapVO> createExprMap(
		SysBeanHelpExprMapVO beanHelpExprMap, String helpExprOid) throws ServiceException, Exception {
	if (beanHelpExprMap==null || super.isBlank(helpExprOid)) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
	}
	SysBeanHelpExprVO sysBeanHelpExpr = new SysBeanHelpExprVO();
	sysBeanHelpExpr.setOid(helpExprOid);
	DefaultResult<SysBeanHelpExprVO> mResult = this.sysBeanHelpExprService.findObjectByOid(sysBeanHelpExpr);
	if (mResult.getValue()==null) {
		throw new ServiceException(mResult.getSystemMessage().getValue());
	}
	sysBeanHelpExpr = mResult.getValue(); // 查看有沒有資料
	beanHelpExprMap.setHelpExprOid( sysBeanHelpExpr.getOid() );		
	return this.sysBeanHelpExprMapService.saveObject(beanHelpExprMap);
}
 
Example #16
Source File: ResourcesServiceImpl.java    From ueboot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 删除资源
 * 删除时,需要先删除权限以及子节点资源
 *
 * @param ids 要删的资源ID列表
 */
@Override
@Transactional(rollbackFor = Exception.class, timeout = 60, propagation = Propagation.REQUIRED)
public void deleteResource(Long[] ids) {
    for (Long i : ids) {
        //先删权限
        List<Permission> permissions = this.permissionRepository.findByResourceId(i);
        if (!permissions.isEmpty()) {
            this.permissionRepository.deleteAll(permissions);
        }
        //删除子节点
        List<Resources> resources = this.resourcesRepository.findByParentId(i);
        if (!resources.isEmpty()) {
            this.resourcesRepository.deleteAll(resources);
        }
        //删除自己
        this.resourcesRepository.deleteById(i);


        // 删除资源日志记录
        String optUserName = (String) SecurityUtils.getSubject().getPrincipal();
        this.shiroEventListener.deleteResourceEvent(optUserName, ids);
    }
}
 
Example #17
Source File: UserApplicationServiceImpl.java    From MultimediaDesktop with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public ListDto<UserAppDto> findDesktopUserApp(String userId) {

	ListDto<UserAppDto> response = new ListDto<>(UserConstant.ERROR);

	try {
		StringUtils.isValidString(userId, "账号不允许为空");
		List<UserApplication> apps = userApplicationRepository
				.findByDesktopIconTrueAndUser(new User(userId));
		response.setData(userAppConvert.covertToDto(apps));
		response.setResult(UserConstant.SUCCESS);
	} catch (VerificationException e) {
		response.setErrorMessage(e.getMessage());
	}

	return response;
}
 
Example #18
Source File: WarningServiceImpl.java    From fastdfs-zyc with GNU General Public License v2.0 5 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED)
public List<WarningUser> findWarUser() throws IOException, MyException {
    //To change body of implemented methods use File | Settings | File Templates.
    List<WarningUser> warningUsers = new ArrayList<WarningUser>();
    Session session = getSession();
    StringBuilder queryString = new StringBuilder("from WarningUser as w");
    Query query = session.createQuery(queryString.toString());
    warningUsers = query.list();
    return warningUsers;
}
 
Example #19
Source File: JobServiceImpl.java    From fastdfs-zyc with GNU General Public License v2.0 5 votes vote down vote up
@Override
@Scheduled(cron = "0 0 0 0/1 * ?")
@Transactional(propagation = Propagation.REQUIRED)
public void updateGroupByDay() throws IOException, MyException, JSchException {
    logger.info("group day data upate begin...");
    List<GroupDay> groups = getGroupInfoByDay();
    Session session = getSession();
    for (GroupDay group : groups) {
        session.save(group);
    }
    logger.info("group day data upated end");
}
 
Example #20
Source File: RelationalTableRegistrationHelperServiceImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
@PublishNotificationMessages
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectData updateRelationalTableSchema(RelationalTableRegistrationDto relationalTableRegistrationDto, List<SchemaColumn> schemaColumns)
{
    return updateRelationalTableSchemaImpl(relationalTableRegistrationDto, schemaColumns);
}
 
Example #21
Source File: ProductService.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Transactional (readOnly=true, propagation=Propagation.REQUIRED)
@Cacheable (value = {"indexes"}, key = "#product_id")
public List<MetadataIndex> getIndexes(Long product_id)
{
   Product product = productDao.read (product_id);
   if (product == null) return new ArrayList<MetadataIndex> ();
   Hibernate.initialize (product.getIndexes ());
   return product.getIndexes ();
}
 
Example #22
Source File: AnnotationConfigTransactionalTestNGSpringContextTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void autowiringFromConfigClass() {
	assertNotNull(employee, "The employee should have been autowired.");
	assertEquals(employee.getName(), "John Smith");

	assertNotNull(pet, "The pet should have been autowired.");
	assertEquals(pet.getName(), "Fido");
}
 
Example #23
Source File: StaffServiceBean.java    From bbs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 根据用户账号取得权限名称
 *@param userAccount 用户账号
 *@return
 */
@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
private List<String> loadUserAuthorities(String userAccount) {
	
	Query query = em.createQuery("" +
			"select a.name from SysPermission a,SysRolesPermission b," +
			"SysUsersRoles c where a.id = b.permissionId and " +
			"b.roleId = c.roleId and c.userAccount = ?1");
			query.setParameter(1, userAccount);
	return query.getResultList();	
}
 
Example #24
Source File: PersonalAddressDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param obj
 * @return the generated identifier.
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public Serializable saveOrUpdate(final PersonalAddressDO obj)
{
  if (internalUpdate(obj) == true) {
    return obj.getId();
  }
  return internalSave(obj);
}
 
Example #25
Source File: UserService.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * THIS METHOD IS NOT SAFE: IT MUST BE REMOVED.
 * TODO: manage access by page.
 * @param user_uuid
 * @return
 */
@PreAuthorize ("hasRole('ROLE_DATA_MANAGER')")
@Transactional (readOnly=true, propagation=Propagation.REQUIRED)
public List<Long> getAuthorizedProducts (String user_uuid)
{
   return productDao.getAuthorizedProducts (user_uuid);
}
 
Example #26
Source File: OrganizationLogicServiceImpl.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
/**
 * 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
 * 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
 */
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
		propagation=Propagation.REQUIRED, 
		readOnly=false,
		rollbackFor={RuntimeException.class, IOException.class, Exception.class} )		
@Override
public DefaultResult<String> createOrgChartData(String basePath, OrganizationVO currentOrganization) throws ServiceException, Exception {
	if (null != currentOrganization && !super.isBlank(currentOrganization.getOid())) {
		currentOrganization = this.findOrganizationData( currentOrganization.getOid() );
	}
	List<Map<String, Object>> treeMap = this.getTreeData(basePath, false, "");
	if (null == treeMap || treeMap.size() < 1) {
		throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
	}
	this.resetTreeMapContentForOrgChartData(treeMap, currentOrganization);
	Map<String, Object> rootMap = new HashMap<String, Object>();
	rootMap.put("name", "Organization / Department hierarchy");
	rootMap.put("title", "hierarchy structure");
	rootMap.put("children", treeMap);
	
	ObjectMapper objectMapper = new ObjectMapper();
	String jsonData = objectMapper.writeValueAsString(rootMap);		
	String uploadOid = UploadSupportUtils.create(
			Constants.getSystem(), 
			UploadTypes.IS_TEMP, 
			false, 
			jsonData.getBytes(), 
			SimpleUtils.getUUIDStr() + ".json");			
	
	DefaultResult<String> result = new DefaultResult<String>();
	result.setValue(uploadOid);
	result.setSystemMessage( new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)) );
	return result;
}
 
Example #27
Source File: Message01ServiceImpl.java    From pmq with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void deleteDy(String tbName, long start, long end) {
	try {
		setMaster(true); 
		message01Repository.deleteDy(getDbName() + "." + tbName, start, end);
	} catch (Exception e) {
		otherFailCounter.inc();
		throw new RuntimeException(e);
	} finally {
		clearDbId();
	}
}
 
Example #28
Source File: HelpTypeServiceBean.java    From bbs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 根据分类查询所有父类帮助分类
 * @param helpType 分类
 * @return
 */
@Transactional(readOnly=true, propagation=Propagation.NOT_SUPPORTED)
public List<HelpType> findAllParentById(HelpType helpType){
	List<HelpType> helpTypeList = new ArrayList<HelpType>();
	//查询所有父类
	if(helpType.getParentId() >0){
		List<HelpType> list = this.findParentById(helpType.getParentId(),new ArrayList<HelpType>());
		helpTypeList.addAll(list);
	}
	//倒转顺序
	Collections.reverse(helpTypeList);
	return helpTypeList;
}
 
Example #29
Source File: PaymentServiceBean.java    From bbs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 根据Id查询在线支付接口
 * @param onlinePaymentInterfaceId 在线支付接口Id
 * @return
 */
@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
public OnlinePaymentInterface findOnlinePaymentInterfaceById(Integer onlinePaymentInterfaceId){
	Query query =  em.createQuery("select o from OnlinePaymentInterface o where o.id=?1");
	//给SQL语句设置参数
	query.setParameter(1, onlinePaymentInterfaceId);
	List<OnlinePaymentInterface> onlinePaymentInterfaceList= query.getResultList();
	if(onlinePaymentInterfaceList != null && onlinePaymentInterfaceList.size() >0){
		for(OnlinePaymentInterface o: onlinePaymentInterfaceList){
			return o;
		}
	}
	return null;
}
 
Example #30
Source File: Message01ServiceImpl.java    From pmq with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public int deleteOldFailMsg(String tbName, long id, int retryCount) {
	try {
		setMaster(true);
		return message01Repository.deleteOldFailMsg(getDbName() + "." + tbName, id, retryCount);
	} finally {
		clearDbId();
	}
}