【发布时间】:2012-07-19 19:40:30
【问题描述】:
我参考了以下 Spring 文档:http://static.springsource.org/spring-data/data-jpa/docs/1.1.0.RELEASE/reference/html/#repositories.custom-behaviour-for-all-repositories
我正在尝试理解上述 Jpa 自定义存储库背后的逻辑。
我的猜测是我必须创建一个 UserRepository 接口(在我的情况下 User 是特定实体)扩展 MyRepository 接口和然后使用适当的参数类型为其提供实现。然后,每个实体都有一个存储库,每个存储库共享 MyRepository 接口中定义的许多常用方法。
这引发了几个问题:
一:如果我要跨多个实体执行操作怎么办:我使用哪个存储库? 二:Spring Data Jpa 是否允许没有任何类型参数的存储库?
【问题讨论】:
标签: spring repository spring-data-jpa