sql查询语句 ,其中 realPrice 是别名
@Query(value = "select *,case when db.order_type_code = 'Db2bOrder' then d.RealTotal else df.TotalMoney end realPrice from db2border_bill_detail db " +
"left join db2border d on d.fID =db.source_id " +
"left join db2brefund df on df.OrderID = db.source_id where db.group_id = ?1 and db.db2border_bill_id = ?2", nativeQuery = true)
List<Db2BorderBillDetail> findAllByGroupIdAndDb2BorderBillId(String groupId,Long Id);
在Db2BorderBillDetail实体类增加对应字段,这样查询正常 ,返回的realPrice的字段有值 ,但是发现保存报错 提示“Unknown column 'db2borderb0_.realPrice' in 'field list'”
@Transient()
private BigDecimal realPrice;
public BigDecimal getRealPrice() {
return realPrice;
}
public void setRealPrice(BigDecimal realPrice) {
this.realPrice = realPrice;
}
改成这样 则保存正常,但是sql查询的值就为null
private BigDecimal realPrice;
@Transient()
public BigDecimal getRealPrice() {
return realPrice;
}
public void setRealPrice(BigDecimal realPrice) {
this.realPrice = realPrice;
}
求大神赐教下,怎么才能查询保存都正常