Returned value is Long when aggregate function count
is used. That's why applicable constructors are:
public CountItemLike(int itemId, Long likes){
this.itemId = itemId;
this.likes = likes.intValue();
}
or:
public CountItemLike(int itemId, long likes){
this.itemId = itemId;
this.likes = (int) likes;
}
Maybe there is additionally type mismatch between ItemLike.itemId and int
, but that cannot be seen from the given code.