我正在使用Spring-data-elasticsearch插件从elasticsearch服务器检索信息。以下是存储库类:
public interface ActorRepository extends ElasticsearchRepository<Actor, Integer> {
public Actor findByActorId(Integer actorId);
public Iterable<Actor> findByFirstName(String firstName);
public Page<Actor> findByLastName(String lastName, Pageable pageable);
//public Iterable<Actor> findByLastName(String lastName);
}
ActorRepository的用法:
@Resource
ActorRepository actorRepository;
Actor actor1 = this.actorRepository.findOne(actorId); // Working perfectly
System.out.println("findOne Method :" + actor1);
Iterable<Actor> actors = this.actorRepository.findAll(); // Works perfectly
for(Actor actor : actors) {
System.out.println("Each Actor :" + actor);
}
Actor actor214 = this.actorRepository.findByActorId(214); // Not working. Reurning null
System.out.println("findByActorId214 :" + actor214);
我从上述方法调用中得到了null响应。我不知道我错过了什么。
提示:
在方法调用旁边作为注释,我已经指定了哪个方法可用,哪个方法不可用。
如果需要更多信息,请告诉我。感谢您提前的帮助。