这是我在存储库类中的方法:
@Query("select max(entry_fee) as maxBuyInFee, max(prize) as maxPrize, max(participants_number) as maxParticipants from Tournament tournament")
FilterMaxValues findFilterMaxValues();
这是我的FilterMaxValues类:
public class FilterMaxValues {
private Integer maxBuyInFee;
private Integer maxPrize;
private Integer maxParticipants;
如何将此HQL的结果转换为FilterMaxValues对象?
现在我得到了:
未找到能够从类型转换的转换器 [java.util.HashMap]键入[com.test.FilterMaxValues]
答案 0 :(得分:1)
如果您的FilterMaxValues
不是实体(例如,
interface FilterMaxValues {
Integer getMaxBuyInFee();
Integer getMaxPrize();
Integer getMaxParticipants();
}
答案 1 :(得分:0)
您是否不需要用FilterMaxValues
和@Entity
来注释@Table(name="yourDBTable")
类,以便Spring
可以自动为您进行转换?