我正在尝试使用Entity类上的Spring-Data和NoSQL Redis进行简单的派生查询,由于某种原因,它返回了一个空对象。
我正在使用带有Java 11和spring-boot-starter-data-redis的Springboot 2.1。
以下是我的实体的示例:
@Data
@RedisHash("MyEntity")
public class MyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
//Other attbrts
...
@NotNull
@Indexed
private Long secId;
}
Anf在这里进入我的存储库类:
@Repository
public interface MyEntityRepository extends CrudRepository<MyEntity, Long> {
//other Methods
...
Optional<MyEntity> findByIdAndSecId(Long id, Long secId);
}
当我调用API Get方法时,它应该从我的Redis数据库返回一个值,但不是。这里有人知道如何解决这个问题吗?