Ron*_*ald 3 jpa nativequery spring-data-jpa spring-boot
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.example.dto.ExampleDto]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.data.repository.query.ResultProcessor$ProjectingConverter.convert(ResultProcessor.java:293) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]
Run Code Online (Sandbox Code Playgroud)
当我在使用本机 JPA 查询中返回 2 个值的查询时,会抛出上述错误。我在下面的 DTO 中捕获查询响应:
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ExampleDto {
@Id
private String name1;
private int nameFlag;
}
Run Code Online (Sandbox Code Playgroud)
在 DAO 类中,我调用本机查询如下。该查询在 SQL Developer 中工作并返回 2 条记录。但是当如下调用时,它会抛出上述错误。
List<ExampleDto> getExampleDto = myJPARepository.
.findNameObject(uuid);
Run Code Online (Sandbox Code Playgroud)
DTO 类中有问题,我需要更改。注释?我不确定这里缺少什么,并尽我所能尝试,放入 @Entity 注释,@Data 注释,在调用查询时我无法解决此错误。
更新:与此相关的本机查询是
@Query(value = "select name1, nameFlag from NameTable",
nativeQuery = true, name = "findNameObject where namekey = ?")
List<ExampleDto> findNameObject(
@Param("nameKey") UUID nameKey);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7831 次 |
最近记录: |