I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other
Also you could try changing the UserRepository Interface declaration to below,
public interface UserRepository extends CrudRepository {
@Query(value = "select count(type_id) userCount, type_id, modified_at from "
+ "user_campaign_objective where camp_id = ?1 group by objective_type_id,modified_at", nativeQuery = true)
List getStatsDTO(Long camp_id);
}
The change is : CrudRepository
from CrudRepository < UserEntity, Long>
.
I faced the same issue while using a different data object inside a repository declared with another data object.