【问题标题】:Null check in formula column公式列中的空值检查
【发布时间】:2018-06-04 08:29:11
【问题描述】:

我是grails中可用的公式列:

 static mapping = {
        id generator: 'uuid'
        version false
        merchantTotal formula: "total_amount - penalty_fee"

域:

class Transaction {
    ....
    ............
    @Transient
    BigDecimal merchantTotal

上面的问题是,如果有任何一行在penalty_fee 列中有“null”值,那么表达式的总值将返回为null。我想在公式列中应用 null 检查或将 null 值视为 0。

【问题讨论】:

    标签: hibernate grails grails-orm


    【解决方案1】:

    文档说,公式字段是纯 sql。 像

    这样的映射
    merchantTotal formula: "total_amount - IFNULL(penalty_fee, 0)"
    

    帮助?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-05
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      相关资源
      最近更新 更多