Issue
Hi I am trying to read a list of values from a native Query in JPA .
My Repository Interface is
@Query(value = "SELECT E_MAIL AS email FROM USERS WHERE UID = ?1 ",nativeQuery = true )
public List<AuditPipeLineModel> getAuditPipeLine(@Param("uid") String uid);
My Model Class is
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AuditPipeLineModel {
private String email;
}
Am getting an exception as
No converter found capable of converting from type
[org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to
type [AuditPipeLineModel]
What is the mistake i am doing ?
The Native Query and Model class is much bigger than this , i just avoided it to make it simple.
Solution
try this
@Query(value = "SELECT new package.towards.AuditPipeLineModel(E_MAIL) FROM USERS WHERE UID = ?1 ",nativeQuery = true )
public List<AuditPipeLineModel> getAuditPipeLine(@Param("uid") String uid);
Answered By – tremendous7
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0