I need to map the return of a native query to an object
- Here is my native query
@Query(value = "select collector from relation;", nativeQuery = true)
Stream<RelationStatistics> findRelationsStatistics();
- Here is my object
public class RelationStatistics {
private String collector;
public RelationStatistics(String collector) {
this.collector = collector;
}
public String getCollector() {
return collector;
}
public void setCollector(String collector) {
this.collector = collector;
}
}
- Here is my test
@Test
public void test() {
Stream<RelationStatistics> test = relations.findRelationsStatistics();
test.forEach(item -> System.out.println(item));
}
This test return me :
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [RelationStatistics]
This is an example with only one string attribut but the original native query is a big request so creating an entity will be too difficult.
I have find SqlResultSetMapping
but I don't really understand how to use it properly
If someone have an idea of what its possible to do 0_o