gpt4 book ai didi

hibernate - org.hibernate.PropertyNotFoundException : Could not find setter for flat_rate on class dk. comtalk.billing.server.rating.db.RateDTO 问题

转载 作者:行者123 更新时间:2023-12-04 02:06:53 25 4
gpt4 key购买 nike

在将 SQL 结果转换为 HQL 时出现此异常。 query.setResultTransformer(Transformers.aliasToBean(RateDTO.class)).list()

但我已经为 RateDTO 类中的 flat_rate 列设置了 setter 和 getter

private BigDecimal flatRate;

@Column(name="flat_rate")
public BigDecimal getFlatRate() {
return flatRate;
}

public void setFlatRate(BigDecimal flatRate) {
this.flatRate = flatRate;
}

Mysql DB 中对应的表。谁能帮帮我。

最佳答案

尝试使用addScalar()在调用 query.list()

之前查询对象
final String sql = "select * " + "from international_rate r " + "WHERE LEFT(:called, LENGTH(r.prefix)) = r.prefix " + "and r.valid_from <= :date AND ( r.Valid_to >= :date or r.Valid_to = 0)" + "and r.deleted = 0"; "

sess.createSQLQuery(sql)
.addScalar("flatRate", Hibernate.STRING) //like all properties need to Add
.setResultTransformer(Transformers.aliasToBean(RateDTO.class)).list();

关于hibernate - org.hibernate.PropertyNotFoundException : Could not find setter for flat_rate on class dk. comtalk.billing.server.rating.db.RateDTO 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14193786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com