I am using spring-data-jpa (2.1.7.RELEASE) with hibernate (5.6.9.Final) as implementation -
when using native query with DTO, I am facing below error -
no converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.abc.reports.zyx.dtos.Xcain21
My native query is as below -
@Query(value = "SELECT p.package_id, p.package_name FROM packages p WHERE p.account_id=:accountId AND (CASE WHEN :packageId IS NULL THEN TRUE " +
"WHEN p.package_id LIKE :packageId THEN TRUE ELSE FALSE END) limit :offset, :limit", nativeQuery = true)
List<Xcain21> getPackageByAccountIdAndPackageId(String accountId, String packageId, int offset, int limit);
And my DTO is as below -
package com.exp.reports.traireport.dtos;
import lombok.Value;
@Value
public class Xcain21 {
int packageId;
String packageName;
}
How can i get result of native query automatically mapped to the DTO.