【发布时间】:2016-11-22 03:51:28
【问题描述】:
public interface ConsumerRepository extends CrudRepository<Consumer, Long> {
List<Consumer> findByLastName(String lastName);
List<Consumer> findByFirstName(String firstName);
//List<Consumer> readExistsFirstName(String firstName);
//List<Consumer> getByFirstNameAndLastNameOrderByFirstName();
//Collection<Consumer> findById(Long id);
@Query("select c from Consumer as c where c.firstName like '%?1%'")
Collection<Consumer> findByNameContains(String word);
@Query(value = "SELECT ppc_consumer FROM ppc_consumer WHERE lastname = ?1",
countQuery = "SELECT count(*) FROM ppc_consumer WHERE lastname = ?1",
nativeQuery = true)
Page<Consumer> findByLastname(String lastname, Pageable pageable);
}
但是显示错误“预期不同”,得到 * 因为我在 @Query 注释中使用了 *?请问怎么了?
【问题讨论】:
-
这里为什么要使用原生查询?您实际上可以直接获取 ppc_consumer 记录,对吗?能详细点吗?
-
@developer 你问我一个问题?我需要答案
标签: java spring spring-data-jpa