The query is not returning all the records, i.e all the records whose count is same out of them only of is being returned. Where as the same code of MYSQL workbench works like a charm
JPA Custom Query
public interface BookingRepository extends JpaRepository<Booking, Long> {
@Query("select count(v.source), concat(v.source,'-', v.destination) as bus_route from Booking v group by v.source, v.destination")
public List<Object[]> groupByBus();
}
Query in MYSQL
SELECT count(source), concat(source," - ", destination) as bus_route
FROM booking
GROUP BY source, destination;
As you can see there are two records with count of one, but only one is being returned by Spring data jpa


List<Object[]>toList<Map<String, Object>>