【发布时间】:2014-10-23 04:18:48
【问题描述】:
当转到 spring data rest 中从 /api 页面发现的页面时,如何覆盖 spring 数据存储库以仅选择选定的列。
我添加 findAll 如下 -
public interface UserRepository extends BaseRepository<User, Integer>, UserRepositoryCustom {
@Query("select u from User u where email = :email and password = :password")
@Cacheable(value = "user-cache", key = "#user.login")
@RestResource(exported = false)
public User findUserByEmailAndPassword(@Param("email") String email, @Param("password") String password);
@RestResource(rel = "byEmail", path = "byEmail")
public User findUserByEmail(@Param("email") String email);
@RestResource(rel = "byPhone", path = "byPhone")
public User findUserByPhone(@Param("phone") String phone);
@Override
@Query("select u.id,u.email,u.phone from User u ")
public Page<User> findAll(Pageable pageable);
}
/api/users 报错 -
{"cause":null,"message":"PersistentEntity must not be null!"}
【问题讨论】:
标签: java spring spring-data spring-data-rest