I'm using code below:
@RestResource(exported = false)
public interface TransactionRepository extends CrudRepository<Transaction, Long> {
@Query(value = "SELECT " +
" new com.test.technical.dto.TopMemberDTO(m.id, m.name, m.email, COUNT(t.book_id)) " +
"FROM " +
" member m JOIN transaction t where m.id = t.member_id and t.date_of_issue >= :dateOfIssue and t.date_of_return <= :dateOfReturn " +
"GROUP BY t.member_id ORDER BY COUNT(t.book_id) DESC limit 5", nativeQuery = true)
List<TopMemberDTO> getTopMembers(@Param("dateOfIssue") LocalDateTime dateOfIssue, @Param("dateOfReturn") LocalDateTime dateOfReturn);
Error is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.test.technical.dto.TopMemberDTO(m.id, m.name, m.email, COUNT(t.book_id)) F' at line 1