Java Code Examples for org.springframework.data.repository.query.Param

The following examples show how to use org.springframework.data.repository.query.Param. These examples are extracted from open source projects. 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 Project: DouBiNovel   Source File: IndexController.java    License: Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "/search")
public String search(@Param("name") String name, Model model) {
    MvcResult result = bookAnalysisService.searchByName(name);
    if (!result.isSuccess()) {
        model.addAttribute("msg", result.getMessage());
        return "public/error";
    }
    model.addAttribute("list", result.getVal("list"));
    model.addAttribute("name", name);
    return "front/search/list";
}
 
Example 2
Source Project: txle   Source File: CommandEntityRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE org.apache.servicecomb.saga.alpha.core.Command c "
    + "SET c.status = :toStatus "
    + "WHERE c.globalTxId = :globalTxId "
    + "  AND c.localTxId = :localTxId "
    + "  AND c.status = :fromStatus")
void updateStatusByGlobalTxIdAndLocalTxId(
    @Param("fromStatus") String fromStatus,
    @Param("toStatus") String toStatus,
    @Param("globalTxId") String globalTxId,
    @Param("localTxId") String localTxId);
 
Example 3
Source Project: yugastore-java   Source File: ProductCatalogController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Fetch a listing of products, given a limit and offset.
 */
@RequestMapping(method = RequestMethod.GET, value = "/products", produces = "application/json")
public @ResponseBody ResponseEntity<List<ProductMetadata>> getProducts(@Param("limit") int limit,
                                                                       @Param("offset") int offset) {
  List<ProductMetadata> products = productCatalogServiceRest.getProducts(limit, offset);
  return new ResponseEntity<List<ProductMetadata>>(products, HttpStatus.OK);
}
 
Example 4
Source Project: txle   Source File: MerchantService.java    License: Apache License 2.0 5 votes vote down vote up
public int updateBalanceByMerchantIdRollback(@Param("merchantid") long merchantid, @Param("balance") double balance) {
    try {
        LOG.error("Executing method 'updateBalanceByUserIdRollback'.");
        int result = merchantRepository.updateBalanceById(merchantid, -balance);
        if (result < 1) {
            LOG.error("Failed to execute 'merchantRepository.updateBalanceById([{}], -[{}])'.", merchantid, balance);
        }
        return result;
    } catch (Exception e) {
        JsonObject jsonParams = new JsonObject();
        try {
            jsonParams.addProperty("type", AccidentHandleType.ROLLBACK_ERROR.toInteger());
            jsonParams.addProperty("globaltxid", omegaContext.globalTxId());
            jsonParams.addProperty("localtxid", omegaContext.localTxId());
            jsonParams.addProperty("remark", "Failed to execute Compensable SQL [UPDATE MerchantEntity T SET T.balance = T.balance + " + balance + " WHERE id = " + merchantid + "].");
            MerchantEntity merchantEntity = null;
            try {
                merchantEntity = merchantRepository.findOne(merchantid);
            } catch (Exception e1) {
                // 如果被补偿的接口是因为数据库连接数过大等数据库原因,那么此处findOne方法也会执行失败,所以捕获下
                LOG.error("Failed to execute method 'merchantRepository.findOne([{}])', params [{}].", merchantid, jsonParams.toString(), e1);
            }
            if (merchantEntity != null) {
                jsonParams.addProperty("bizinfo", merchantEntity.toJsonString());
            } else {
                jsonParams.addProperty("bizinfo", "{\"merchantid\": " + merchantid + "}");
            }
            LOG.error("Failed to execute method 'updateBalanceByMerchantIdRollback', params [{}].", jsonParams.toString(), e);
            clientAccidentHandlingService.reportMsgToAccidentPlatform(jsonParams.toString());
        } catch (Exception e2) {
            LOG.error("Failed to report accident for method 'updateBalanceByMerchantIdRollback', params [{}].", jsonParams.toString(), e2);
        }
        // 不要抛出异常,否则org.apache.servicecomb.saga.omega.context.CompensationContext中报(IllegalAccessException | InvocationTargetException)错误
    }
    return 0;
}
 
Example 5
Source Project: txle   Source File: MerchantService.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
@Compensable(compensationMethod = "updateBalanceByMerchantIdRollback")
public int updateBalanceById(@Param("merchantid") long merchantid, @Param("balance") double balance) {
    int result = merchantRepository.updateBalanceById(merchantid, balance);
    // 手动补偿场景:由业务人员自行收集所影响的数据信息
    messageSender.reportMessageToServer(new KafkaMessage(drivername, dburl, dbusername, "txle_sample_merchant", "update", merchantid + ""));
    if (balance > 200) {
        throw new RuntimeException("The 'Merchant' Service threw a runtime exception in case of balance was more than 200.");
    }
    return result;
}
 
Example 6
@Query("MATCH (user:User) WHERE exists(user.pagerank) AND exists(user.screenName) AND coalesce(user.imported, false) = true\n" +
        "WITH user\n" +
        "ORDER BY user.pagerank DESC\n" +
        "SKIP {skip}\n" +
        "LIMIT {limit}\n" +
        "RETURN user")
Set<User> findRankedUsers(@Param("skip") Integer skip, @Param("limit") Integer limit);
 
Example 7
Source Project: txle   Source File: MerchantService.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
@AutoCompensable
public int updateBalanceByIdAuto(@Param("merchantid") long merchantid, @Param("balance") double balance) {
    if (balance == 2) {
        throw new RuntimeException("Merchant auto normal throw exception");
    }
    return merchantRepository.updateBalanceById(merchantid, balance);
}
 
Example 8
@Query(" SELECT childAttribute FROM PluginPackageAttribute childAttribute " +
        "LEFT OUTER JOIN PluginPackageAttribute parentAttribute ON childAttribute.pluginPackageAttribute.id=parentAttribute.id " +
        "LEFT OUTER JOIN PluginPackageEntity entity ON parentAttribute.pluginPackageEntity.id=entity.id " +
        "LEFT OUTER JOIN PluginPackageDataModel dataModel ON entity.pluginPackageDataModel.id=dataModel.id " +
        "WHERE dataModel.packageName=:packageName AND entity.name=:entityName and dataModel.version=:dataModelVersion")
Optional<List<PluginPackageAttribute>> findAllChildrenAttributes(
        @Param("packageName") String packageName,
        @Param("entityName") String entityName,
        @Param("dataModelVersion") int dataModelVersion);
 
Example 9
Source Project: txle   Source File: ComplexScenarioMerchantService.java    License: Apache License 2.0 5 votes vote down vote up
@Transactional
@Compensable(retries = 3, compensationMethod = "updateBalanceByMerchantIdRollback")
public int updateBalanceByIdRetry(@Param("merchantid") long merchantid, @Param("balance") double balance) {
    LOG.error("Executing method 'updateBalanceByMerchantIdRetry'.");
    int result = merchantRepository.updateBalanceById(merchantid, balance);
    if (balance == 2) {
        throw new RuntimeException("Retry, can not deduct money");
    }

    return result;
}
 
Example 10
Source Project: Spring-Boot-Book   Source File: StudentRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Modifying
@Transactional
@Query(value = "update Student a set a.name = :name where a.id =:id")
void updataStudentById(@Param("name") String name, @Param("id") long id);
 
Example 11
Source Project: wecube-platform   Source File: RoleRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select t from SysRoleEntity t where t.name = :name and t.deleted = false")
SysRoleEntity findNotDeletedRoleByName(@Param("name") String name);
 
Example 12
Source Project: wecube-platform   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select t from SysUserEntity t " + " " + "where t.username = :username and t.deleted = false ")
SysUserEntity findNotDeletedUserByUsername(@Param("username") String username);
 
Example 13
Source Project: Spring-Boot-Book   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Modifying(clearAutomatically=true)
@Transactional
@Query("update User set active=:active where email=:email")
int setActive(@Param("active") Integer active, @Param("email") String email);
 
Example 14
Source Project: Spring-Boot-Book   Source File: CartRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select * from cart c where c.user_id=:user_id", nativeQuery = true)
List<Cart> findCartByIdNative(@Param("user_id") long user_id);
 
Example 15
Source Project: ZTuoExchange_framework   Source File: MemberTransactionDao.java    License: MIT License 4 votes vote down vote up
@Query("select sum(t.amount)  as amount from MemberTransaction t where t.flag = 0  and t.memberId = :memberId and t.symbol = :symbol and t.type = :type and t.createTime >= :startTime and t.createTime <= :endTime")
Map<String,Object> findMatchTransactionSum(@Param("memberId") Long memberId,@Param("symbol") String symbol,@Param("type") TransactionType type,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
 
Example 16
Source Project: wecube-platform   Source File: OperationEventRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select t from OperationEventEntity t where t.status = :status ")
List<OperationEventEntity> findAllByStatus(@Param("status") String status);
 
Example 17
Source Project: TASK-Management-System   Source File: TaskRecordRepository.java    License: MIT License 4 votes vote down vote up
@Query("SELECT t FROM TaskRecord t WHERE t.user=:id")
List<TaskRecord> getTaskRecordByUser(@Param("id") long user);
 
Example 18
Source Project: ZTuoExchange_framework   Source File: MemberWalletDao.java    License: MIT License 4 votes vote down vote up
@Transactional
@Modifying
@Query(value = "TRUNCATE TABLE member_wallet_:weekDay",nativeQuery = true)
int dropWeekTable(@Param("weekDay")int weekDay);
 
Example 19
Source Project: wecube-platform   Source File: UserRoleRsRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select t from UserRoleRsEntity t where t.roleId = :roleId and t.deleted = false")
List<UserRoleRsEntity> findAllByRoleId(@Param("roleId") String roleId);
 
Example 20
Source Project: ZTuoExchange_framework   Source File: MemberAddressDao.java    License: MIT License 4 votes vote down vote up
@Modifying
@Query("update MemberAddress a set a.deleteTime=:date,a.status=1 where a.status=0 and a.id=:id and a.memberId=:memberId")
int deleteMemberAddress(@Param("date") Date date, @Param("id") long id, @Param("memberId") long memberId);
 
Example 21
Source Project: codeway_service   Source File: UserDao.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Modifying
@Query("delete from User where id in (:ids)")
void deleteBatch(@Param("ids") List<String> ids);
 
Example 22
Source Project: codeway_service   Source File: ResourceDao.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Query(value = "SELECT * FROM us_resource WHERE id IN (SELECT resource_id FROM us_role_resource WHERE role_id in (:resId))", nativeQuery = true)
Set<Resource> findResourceByRoleIds(@Param("resId") List<String> resId);
 
Example 23
Source Project: wecube-platform   Source File: ProcInstInfoRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select * from core_ru_proc_inst_info where proc_def_id in (:procDefIds) ", nativeQuery = true)
List<ProcInstInfoEntity> findByProcDefIdIn(@Param("procDefIds") List<String> procDefIds);
 
Example 24
Source Project: ZTuoExchange_framework   Source File: MemberApplicationDao.java    License: MIT License 4 votes vote down vote up
@Query(value = "select count(1) from member_application where  id_card = :idCard and audit_status=0",nativeQuery = true)
int queryByIdCard(@Param("idCard") String idCard);
 
Example 25
Source Project: ZTuoExchange_framework   Source File: ExchangeOrderRepository.java    License: MIT License 4 votes vote down vote up
@Query(value="select coin_symbol unit,FROM_UNIXTIME(completed_time/1000, '%Y-%m-%d'),sum(traded_amount) amount from exchange_order where FROM_UNIXTIME(completed_time/1000, '%Y-%m-%d') = :date and direction = 1 and status = 1 group by unit",nativeQuery = true)
List<Object[]> getExchangeTurnoverCoin(@Param("date") String date);
 
Example 26
Source Project: wecube-platform   Source File: SubSystemRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query("select t from SysSubSystemEntity t " + " where t.systemCode = :systemCode ")
SysSubSystemEntity findOneBySystemCode(@Param("systemCode")String systemCode);
 
Example 27
Source Project: codeway_service   Source File: LoginLogDao.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Modifying
@Query("delete from LoginLog where id in (:ids)")
void deleteBatch(@Param("ids") List<String> ids);
 
Example 28
Source Project: ZTuoExchange_framework   Source File: OrderDao.java    License: MIT License 4 votes vote down vote up
@Modifying
@Query("update Order a set a.releaseTime=:date,a.status=:status where  (a.status=2 or a.status=4) and a.orderSn=:orderSn")
int releaseOrder(@Param("date") Date date, @Param("status") OrderStatus status, @Param("orderSn") String orderSn);
 
Example 29
Source Project: we-cmdb   Source File: AdmCiTypeAttrGroupRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "select count(1) from adm_ci_type_attr_group where id_adm_ci_type_attr in :attrIds GROUP BY id_adm_attr_group", nativeQuery = true)
List<BigInteger> countByCiTypeAttrIds(@Param("attrIds") List<Integer> attrIds);
 
Example 30
Source Project: we-cmdb   Source File: AdmCiTypeAttrRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Query(value = "SELECT * FROM adm_ci_type_attr WHERE id_adm_ci_type = :ciTypeId and edit_is_null =:isNullable AND is_auto = :isAuto", nativeQuery = true)
List<AdmCiTypeAttr> findWithNullableAndIsAuto(@Param("ciTypeId") int ciTypeId, @Param("isNullable") int isNullable, @Param("isAuto") int isAuto);