我正在使用JPA使用Spring Boot开发应用程序.在应用程序中,我公开了一个rest API.我不想使用Spring数据休息,因为我想完全控制数据.
我无法弄清楚如何动态使用EntityGraph.
假设我从这里采取了以下模型
@Entity
class Product {
@ManyToMany
Set<Tag> tags;
// other properties omitted
}
interface ProductRepository extends Repository<Customer, Long> {
@EntityGraph(attributePaths = {"tags"})
Product findOneById(Long id);
}
Run Code Online (Sandbox Code Playgroud)
我有以下休息链接访问产品 http:// localhost:8090/product/1
它返回给我一个id为1的产品
问题:
我找到了这篇文章,但不确定这有多大帮助.