spring jpaspecificationexecutor找不到类型alarm的属性findall

7ivaypg9  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(403)

我使用redis存储我的应用程序的报警,实体如下:

@RedisHash("alarm")
public class Alarm implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long id;

    @Indexed
    private String name;

    @Indexed
    private String createdAt;

    @Indexed
    private String createdBy;

    @Indexed
    private String clearAt;

    @Indexed
    private String clearBy;
}

数据源配置如下:

@Configuration
@EnableRedisRepositories(basePackages = "com.app.demo.redis.repository")
public class RedisDataSourceConfiguration {

@Autowired
private RedisProperties redisProperties;

@Bean
public JedisConnectionFactory jedisConnectionFactory(){
    RedisStandaloneConfiguration redisConfiguration = new RedisStandaloneConfiguration();
    return new JedisConnectionFactory();
    }

@Bean
public RedisTemplate<Object, Object> redisTemplate(){
    RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
    template.setConnectionFactory(jedisConnectionFactory());
    }
}

这是存储库:

@Repository
public interface AlarmRedisRepository extends JpaRepository<Alarm, Long>, JpaSpecificationExecutor<Alarm>{
}

我曾经 Specification 自定义搜索:

public class AlarmSpecification implements Specification<Alarm>{
    private Alarm filter;

    public AlarmSpecification(Alarm alarm){
        this.alarm = alarm;
    }

    @Override
    public Predicate toPredicate(Root<Alarm> root, CriteriaQuery<?> query, CriteriaBuilder builder){
            // This is where I added the filter
            Predicate predicate = builder.disjunction();
            return predicate;
    }
}

在我的 @Service :

@Autowired
private AlarmRedisRepository repo;

Pageable pageable = .....
Alarm alarm = .....
Specification<Alarm> specification = new AlarmSpecification(alarm);
Page<Alarm> page = repo.findAll(specification, pageable);

它返回错误作为标题。任何曾经使用redis和specification的人都可以帮助我!!!提前感谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题