代码之家  ›  专栏  ›  技术社区  ›  Stéphane GRILLON

Spring数据存储库——查找列表中的where字段和其他字段是否正常

  •  1
  • Stéphane GRILLON  · 技术社区  · 6 年前

    我读了官方的《春季医生》( https://docs.spring.io/spring-data/jpa/docs/current/reference/html/ )

    In      findByAgeIn(Collection<Age> ages) … where x.age in ?1
    
    NotIn   findByAgeNotIn(Collection<Age> ages) … where x.age not in ?1
    

    我的错误是:

    Caused by: java.lang.NoSuchMethodError: com.project.dao.DeviceRepository.findBySiteAndTypeIn(Lcom/project/model/Site;Ljava/util/List;)Ljava/util/List;
    

    我正在尝试将spring Crudepository与查找设备结合使用,其中的类型在列表中:

    public interface DeviceRepository extends CrudRepository<Device, Long> {
    
        List<Device> findBySiteAndTypeIn(Site site, List<String> types);
    
    }
    

    此代码正常,但没有列表:

    public interface DeviceRepository extends CrudRepository<Device, Long> {
    
        List<Device> findBySiteAndType(Site site, String type);
    
    }
    
    0 回复  |  直到 6 年前