Announcement Announcement Module
Collapse
No announcement yet.
spring-data @Query mapping result issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-data @Query mapping result issue

    Hello,

    I've created a Repository that extends CrudRepository<Item, Long>,
    this repository has a method with an @Query notation:

    Code:
    @Query("select itemType, count(*) as count from Item where  User_id = :userId group by itemType")
    List<Map<String, Long>> countItemsForUser(@Param("userId") Long userId);
    The issue I'm having is that this return a List of Objects and not a List of Map<String,Long>.
    I've read somewhere that JPA can't return a Map so that's why I stuff the result in a List<Map<String,Long>>.

    I don't know what's the best way to work around this issue or to quickly access the result data.
Working...
X