【发布时间】:2016-12-19 15:06:42
【问题描述】:
当我在 Spring Boot 中使用 @query 注释运行以下查询时,它会返回正确的结果:
SELECT p FROM Collection p WHERE LOWER(p.description) LIKE LOWER(CONCAT('%',:searchTerm, '%'))
{
"_embedded": {
"collections": [
{
"place": "Blessington",
"description": "Collection of old shoes for recycling",
"_links": {
"self": {
"href": "http://localhost:8080/collections/1"
},
"collection": {
"href": "http://localhost:8080/collections/1"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/collections/search/findByDescription?searchTerm=shoe"
}
}
}
当我尝试指定要返回的字段时:
SELECT p.description FROM Collection p WHERE LOWER(p.description) LIKE LOWER(CONCAT('%',:searchTerm, '%'))
我收到以下错误:
{
"cause": null,
"message": "PersistentEntity must not be null!"
}
如何在 Spring Data 中使用 @query 注解指定返回哪些字段?
【问题讨论】:
标签: spring-data-rest