以下是例外:
org.springframework.dao.InvalidDataAccessApiUsageException: Encountered array-valued parameter binding, but was expecting [java.lang.String (n/a)];
nested exception is java.lang.IllegalArgumentException: Encountered array-valued parameter binding, but was expecting [java.lang.String (n/a)]
这是我的存储库:
@Repository
public interface FirmRepository extends JpaRepository<Firm, Integer> {
Page<Firm> findAll(Pageable page);
List<Firm> findByParentFirm(Firm firm);
@Query(value = "FROM Firm WHERE name = :name")
Firm findByName(@Param("name") final String[] name);
}
这是我的服务:
/**
* Gets the Application type by name
*/
public Firm getFirmByName(final String[] name) throws ResourceNotFoundException, ForbiddenOperationException {
//LOGGER.debug("Getting the firm with name=[{}]", strings);
return firmRepository.findByName(name);
}
}
答案 0 :(得分:0)
以下内容应该有效
@Query( "FROM Firm WHERE name in :names" )
List<Firm> findByName(@Param("names") List<String> firmNames);
您可以将数组转换为列表List<String> firmNames = Arrays.asList(names);