如何使用JPA和Spring查找列表中字段的不同行?
我正在使用Spring连接到db。我有一个扩展的接口 这是我想在db上执行的查询:.我宁愿在没有任何sql注释的情况下执行此操作,因此,如果没有,那就好了。CrudRepository<People, Long>
SELECT DISTINCT name FROM people WHERE name NOT IN UserInputSet
NOT
有没有办法做到这一点?我看了看春天的文档,但我找不到任何东西(http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation)
这就是我累了,但它不起作用。
@Query("SELECT DISTINCT name FROM people WHERE name NOT IN (?1)")
List<String> findNonReferencedNames(List<String> names);
这是我得到的例外:
Error creating bean with name 'peopleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List de.test.tasks.persistence.PeopleRepository.findNonReferencedNames(java.util.List)!
和
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: people is not mapped [SELECT name FROM people WHERE name NOT IN (?1)]