I use spring boot 3. I try to create a native query with entity manager, i would like to feed a dto
@SqlResultSetMapping(
name = "BookResultMapping",
classes = @ConstructorResult(
targetClass = BookSearchResult.class,
columns = {
@ColumnResult(name = "code"),
@ColumnResult(name = "title")}))
public class BookSearchService {
@PersistenceContext
private EntityManager entityManager;
public void bookSearch(Search search){
StringBuilder sbSqlQuery = new StringBuilder();
...
Query query = entityManager.createNativeQuery(sbSqlQuery.toString(), "BookResultMapping");
...
}
}
@Data
@RequiredArgsConstructor
public class BookSearchResult {
private String code;
private String title;
}
When i run this code, I get
Could not resolve specified result-set mapping name : BookResultMapping
Edit, I tried to but code related to SqlResultSetMapping directly to the dto, but i get same result