This query here is basically working as intended:
@Query("SELECT " +
" votedItem.groupVoting.id AS votingId, " +
" COUNT(votedItem) AS nbVotes " +
"FROM VotingVotedItemEntity votedItem " +
"WHERE votedItem.id IN :votingIds " +
"GROUP BY votedItem.id, votedItem.item.id")
List<Object> findItemVoteCountsByVotingIds(@Param("votingIds") List<Long> votingIds);
My problem is I can't get the result into an object. The query is not final but in the end it should be mapped into a class:
public class ItemVotes
{
private String name;
private Integer voteCount;
/* Getter & setter */
}
I don't know what the way to go is here. At this point I think I'd have to create it's own JpaRepository
:
public interface VoteCountsRepository extends JpaRepository<ItemVotes, Long> {
}
but this does not work as the server dies on startup to a
IllegalArgumentException
: Not a managed type
Can somebody explain to me how to map custom types into objects here?