简体   繁体   English

用 jpql 过滤 redis 数据不起作用

[英]filtering redis data with jpql does not work

Is it possible to create a JPQL filter with redis?是否可以使用 redis 创建 JPQL 过滤器?

if I try this:如果我试试这个:

List<ContingencyDTO> findAll();

works:作品:

but if i try with jpql no.但如果我尝试使用 jpql no。

@Repository
public interface ContingencyRepository extends 
CrudRepository<ContingencyDTO,Integer>, QueryByExampleExecutor<ContingencyDTO>  
{

List<ContingencyDTO> findByInitialZipCodeLessThanEqual(Long initialZipCode);

}

return this message error: Erro:: handleAPIException:: Exception返回此消息错误:Erro::handleAPIException::Exception

org.springframework.dao.InvalidDataAccessApiUsageException: LESS_THAN_EQUAL (1): [IsLessThanEqual, LessThanEqual] is not supported for Redis query derivation;. org.springframework.dao.InvalidDataAccessApiUsageException: LESS_THAN_EQUAL (1): [IsLessThanEqual, LessThanEqual] is not supported for Redis query derivation;. nested exception is java.lang:IllegalArgumentException: LESS_THAN_EQUAL (1), [IsLessThanEqual, LessThanEqual] is not supported for Redis query derivation!嵌套异常是 java.lang:IllegalArgumentException: LESS_THAN_EQUAL (1), [IsLessThanEqual, LessThanEqual] is not supported for Redis query derivation!


I tryed upate in DTO the filtered values to @Indexed but dont work.我尝试在 DTO 中将过滤后的值更新为 @Indexed 但不起作用。

private @Indexed Long initialZipCode;

Please check the attribute name in Entity ContingencyDTO .请检查 Entity ContingencyDTO中的属性名称。 If the attribute name is zipcode , then above method should have worked.如果属性名称是zipcode ,那么上述方法应该有效。 If the attribute name is zipCode then the method name should be findByZipCode .如果属性名称是zipCode ,那么方法名称应该是findByZipCode

If you want to retrieve all ContingencyDTO entities for a given zipCode then List<ContingencyDTO> findByZipCode(String zipCode);如果要检索给定邮政编码的所有ContingencyDTO实体,则 List<ContingencyDTO> zipCode List<ContingencyDTO> findByZipCode(String zipCode); should work.应该管用。 @Query annotation isn't required in this case and in above case too, if the issue is solved as per this explanation.在这种情况下和上述情况下都不需要 @Query 注释,如果按照这个解释解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM