Проблема с отображением набора результатов объекта в POJO.
Объект использует hibernate resultsetmap из кортежа и должен передавать аннотированные значения в конструктор POJO.
Entity
@SqlResultSetMapping(
name = "TaskChangeMapping",
columns = {
@ColumnResult(name = "id", type = Long.class),
@ColumnResult(name = "status", type = String.class),
@ColumnResult(name = "data_values", type = String.class)
})
@NamedNativeQueries({
@NamedNativeQuery(
name = "ICreateChange.listStartedChangesByInitiator",
query =
"SELECT id, status, data_values "
+ "FROM icreate_change "
+ "WHERE initiator = :initiator "
+ "AND workflow_process_id = 0",
resultSetMapping = "TaskChangeMapping"
),
@NamedNativeQuery(
name = "ICreateChange.listDataValuesAndStatusByChangeId",
query =
"SELECT id, status, data_values "
+ "FROM icreate_change "
+ "WHERE id = :changeId",
resultSetMapping = "TaskChangeMapping"
)
})
@Data
@Entity
@Table(name = "icreate_change")
public class ICreateChange {
...
Это класс POJO
ChangeTask
@Data
public class ChangeTask {
@Getter
@Value("id")
private Long id;
@Getter
@Value("status")
private String status;
@Getter
@Value("data_values")
@JsonInclude(Include.NON_NULL)
private String dataValues;
/**
* Constructor.
* @param id changeId
* @param status change status
* @param dataValues JSON string of data values
*/
public ChangeTask(
Long id,
String status,
String dataValues
) {
this.id = id;
this.status = status;
this.dataValues = dataValues;
}
}
Репозиторий
Обратите внимание, что нет контроллера покоя, он направлен прямо в хранилище
@CrossOrigin
@RepositoryRestResource(path = "/iCreateChange")
public interface ICreateChangeRepository extends JpaRepository<ICreateChange, Long> {
List<ChangeTask> listDataValuesAndStatusByChangeId(
@Param("changeId")
@RequestParam
@ApiParam(name = "changeId", value = "changeId")
Long changeId);
}
При вызове listDataValuesAndStatusByChangeId
происходит следующая трассировка стека
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.jlr.ddc.cmpdataapi.model.ChangeTask]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.data.repository.query.ResultProcessor$ProjectingConverter.convert(ResultProcessor.java:293) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.lambda$and$0(ResultProcessor.java:213) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:224) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:152) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:141) ~[spring-data-jpa-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125) ~[spring-data-jpa-2.1.2.RELEASE.jar:2.1.2.RELEASE]
Есть идеи?