我做了一个应该暴露嵌套实体的投影:
@Projection(name = "inlineBusiness", types = { UserModel.class })
public interface InlineBusinessUserModelProjection {
String getUsername();
String getFirstName();
String getLastName();
Date getBirthdate();
String getEmail();
BusinessModel getBusiness();
}
Run Code Online (Sandbox Code Playgroud)
和服务存储库:
@RepositoryRestResource(collectionResourceRel = "users", path = "users",
excerptProjection = InlineBusinessUserModelProjection.class)
public interface UserRepository extends BaseDAO<UserModel> {..}
Run Code Online (Sandbox Code Playgroud)
因为/users它工作正常,业务领域暴露与嵌套实体,但当我调用/users/1- 没有,也所有自定义方法..似乎投影不参与任何方法除了/users
任何想法?
我有一个标准的Spring数据JPA和Spring数据Rest设置,它正确地返回关联作为正确资源的链接.
{
"id": 1,
"version": 2,
"date": "2011-11-22",
"description": "XPTO",
"_links": {
"self": {
"href": "http://localhost:8000/api/domain/1"
},
"otherDomain": {
"href": "http://localhost:8000/api/domain/1/otherDomain"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是在某些请求中,我希望扩展与"otherDomain"的关联(因此客户端不必执行N + 1个请求来获取完整数据).
是否可以配置Spring Data Rest以这种方式处理响应?