Spring JPA :: No converter found capable of converting from type

You can use the constructor expression JPQL query, your query looks like this:

select new StatsDTO(count(u),u.typeId,u.modifiedAt) from UserCampaignObjective u where campId = ? group by objectiveTypeId,modifiedAt

But you make sure the constructor StatsDTO existed already.


You can solve this issue and achieve the result by using projections by making your DTO an interface with getters for columns returned by the query. That's what I did when I faced the same issue.

For example in your case change StatsDTO to interface like shown below, make sure to give alias for your columns if you are using '.' operator:

public interface StatsDTO {
    Integer getUserCount();
    Byte getTypeId();
    Instant getModifiedAt();
}

Also in your query give alias for your columns like userCount, typeId, modifiedAt respectively so that it is mapped correctly.