vendredi 6 mars 2015

Select one column using Spring Data JPA

Does anyone have any idea how to get one or fewer columns using Spring Data JPA? I created a repository like below in my Spring Boot project, but always get the '{"cause":null,"message":"PersistentEntity must not be null!"}' error when accessing the Restful URL.





@RepositoryRestResource(collectionResourceRel = "users", path = "users")
public interface UsersRepository extends CrudRepository<Users, Integer> {

@Query("SELECT u.userName FROM Users u")
public List<String> getUserName();
}



Then if I access the Restful URL like '../users/search/getUserName', I get the error: '{"cause":null,"message":"PersistentEntity must not be null!"}'


Aucun commentaire:

Enregistrer un commentaire