use*_*181 6 java hibernate spring-data-jpa spring-boot jhipster
我想创建自定义存储库:
public interface FriendRepositoryCustom {
Page<Friend> findFriends(FriendCriteria friendCriteria, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)
及其实现:
@Repository
@Transactional(readOnly = true)
public class FriendRepositoryCustomImpl implements FriendRepositoryCustom {
@PersistenceContext
EntityManager entityManager;
@Override
public Page<Friend> findFriends(FriendCriteria friendCriteria, Pageable pageable) {
...
}
Run Code Online (Sandbox Code Playgroud)
并将其添加到主存储库:
@Repository
public interface FriendRepository extends JpaRepository<Friend, Long>, JpaSpecificationExecutor<Friend>, FriendRepositoryCustom {
}
Run Code Online (Sandbox Code Playgroud)
当我启动应用程序时,出现此错误:
由以下原因引起:org.springframework.data.mapping.PropertyReferenceException:未找到类型为Friend的属性findFriends!在org.springframework.data.mapping.PropertyPath。(PropertyPath.java:77)在org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)在org.springframework.data.mapping.PropertyPath.create( org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)上的PropertyPath.java:309)org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)上的org.springframework.data org.springframework.data.repository.query.parser.PartTree $ OrPart。(PartTree.java:247)的org.springframework.data.repository.query的.repository.query.parser.Part。(Part.java:76) org.springframework.data.repository的.parser.PartTree $ Predicate.buildTree(PartTree.java:398)。
Jen*_*der 11
您可能将实现类命名为错误。
请注意,命名期望随着Spring Data 2.0的改变而改变。
对于<2.0,必须将实现命名为带有附加Impl后缀的最终存储库接口。有关示例,请参见匹配的参考文档。
对于> = 2.0,必须将实现命名为带有附加Impl后缀的自定义接口。有关示例,请参见当前参考文档。
注意:您不需要任何@Repository注释。
| 归档时间: |
|
| 查看次数: |
2462 次 |
| 最近记录: |