【发布时间】:2015-11-18 10:24:19
【问题描述】:
我有一个Entity
@Entity
@Table(name = "orgtree")
public class OrganizationTree {
@Id
@Column(name="ORGANIZATION_ID")
private String organizationId;
@Column(name="ORGANIZATION_NAME")
private String organizationName;
}
以及提供 REST 访问的存储库
@RepositoryRestResource(collectionResourceRel = "organizationTree", path = "organizationTree")
public interface OrganizationTreeRepository extends JpaRepository<OrganizationTree,String> {
@Query
@RestResource(path = "findAll", rel = "findAll")
List<OrganizationTree> findAll();
}
到目前为止一切顺利。
现在我想向我的实体添加一个计算字段
@Autowired
@Transient
private OrgTreeService orgTreeService;
@JsonSerialize
public Integer getPersonCount() {
return orgTreeService.getPersonCount(organizationId);
}
这里我有几个问题:
- orgTreeService 为空
- 人们说使用 实体中的服务
这个问题的典型解决方案是什么?
【问题讨论】:
标签: spring hibernate spring-boot