【问题标题】:Couldn't find PersistentEntity for type class org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap找不到类型类 org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap 的 PersistentEntity
【发布时间】:2019-12-14 09:28:08
【问题描述】:

在尝试使用 Query 获取数据并暴露为 API 获取异常时

@Repository
public interface EmployeeRepository extends JpaRepository<Employee, 
String> {

@Query(value="Select * from Employee",nativeQuery = true)
 @RestResource(path = "byEmp", rel = "byEmp")
 List<Map> findTest();

 }

网址:http://localhost:8080/employeeEntities/search/byEmp

例外:

java.lang.IllegalArgumentException: Couldn't find PersistentEntity for type class org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap!
    at org.springframework.data.mapping.context.PersistentEntities.lambda$getRequiredPersistentEntity$2(PersistentEntities.java:78) ~[spring-data-commons-2.0.13.RELEASE.jar:2.0.13.RELEASE]
    at java.util.Optional.orElseThrow(Optional.java:290) ~[na:1.8.0_181]
    at org.springframework.data.mapping.context.PersistentEntities.getRequiredPersistentEntity(PersistentEntities.java:77) ~[spring-data-commons-2.0.13.RELEASE.jar:2.0.13.RELEASE]
    at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:72) ~[spring-data-rest-webmvc-3.0.13.RELEASE.jar:3.0.13.RELEASE]
    at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:55) ~[spring-data-rest-webmvc-3.0.13.RELEASE.jar:3.0.13.RELEASE]
    at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:110) ~[spring-data-rest-webmvc-3.0.13.RELEASE.jar:3.0.13.RELEASE]
    at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.toResources(AbstractRepositoryRestController.java:80) ~[spring-data-rest-webmvc-3.0.13.RELEASE.jar:3.0.13.RELEASE]
    at org.springframework.data.rest.webmvc.RepositorySearchController.lambda$toResource$1(RepositorySearchController.java:209) ~[spring-data-rest-webmvc-3.0.13.RELEASE.jar:3.0.13.RELEASE]
    at java.util.Optional.map(Optional.java:215) ~[na:1.8.0_181].at org.springframework.data.rest.webmvc.RepositorySearchController.toResource.

如果我尝试通过创建方法从任何其他类调用我能够获取记录

【问题讨论】:

    标签: spring-boot spring-data-jpa spring-data-rest


    【解决方案1】:

    列表员工> findTest();

    【讨论】:

      猜你喜欢
      • 2019-07-27
      • 1970-01-01
      • 2018-07-12
      • 1970-01-01
      • 1970-01-01
      • 2020-07-26
      • 2021-10-26
      • 2014-01-25
      • 1970-01-01
      相关资源
      最近更新 更多