@TableField AS 不生效问题

背景

使用@TableField对别名不生效问题

代码
<select id="getMonthDevelopKeepList" resultType="org.zt.task.report.entity.gross.vo.MonthDevelopGrossData">
        SELECT
            bloc,
            department,
            develop_department,
            is_performance,
            IFNULL(SUM(real_income),0) as realIncome,
            IFNULL(SUM(total_income),0) as totalIncomeFinal,
            IFNULL(SUM(refund),0) as refundFinal,
            IFNULL(SUM(commodity_cost),0) as commodityCostFinal,
            IFNULL(SUM(platform_fee),0) as platformFeeFinal,
            IFNULL(SUM(collection_fee),0) as collectionFeeFinal,
            IFNULL(SUM(update_freight),0) as updateFreightFinal,
            IFNULL(SUM(return_update_freight),0) as returnUpdateFreight,
            IFNULL(SUM(update_freight_last),0) as updateFreightLastFinal,
            IFNULL(SUM(packing_material_fee),0) as packingMaterialFeeFinal,
            IFNULL(SUM(capital_cost),0) as capitalCostFinal,
            IFNULL(SUM(publish_fee),0) as publishFeeFinal,
            IFNULL(SUM(marketing_fee),0) as marketingFeeFinal,
            IFNULL(SUM(scramble_fee),0) as scrambleFeeFinal,
            IFNULL(SUM(cloud_host_vps),0) as cloudHostVpsFinal,
            IFNULL(SUM(vps_and_others),0) as vpsAndOthersFinal,
            IFNULL(SUM(fixed_service_fee_allocation),0) as fixedServiceFeeAllocationFinal,
            IFNULL(SUM(other_payments),0) as otherPaymentsFinal,
            IFNULL(SUM(fines_or_temporary_deductions),0) as finesOrTemporaryDeductionsFinal,
            IFNULL(SUM(collection_fees_and_others),0) as collectionFeesAndOthersFinal,
            IFNULL(SUM(service_charge),0) as serviceChargeFinal,
            IFNULL(SUM(vat_fee),0) as vatFeeFinal,
            IFNULL(SUM(month_undertake_amount),0) as monthUndertakeAmountSum,
            IFNULL(SUM(profit_loss),0) as profitLossFinal,
            IFNULL(SUM(month_clear_cost),0) as monthClearCostFinal,
            IFNULL(SUM(destroy_cost),0) as destroyCostFinal,
            IFNULL(SUM(gross_margin),0) as grossMargin,
            IFNULL(SUM(warehouse_cost),0) as warehouseCostSum,
            IFNULL(SUM(position_fee),0) as positionFeeFinal,
            IFNULL(SUM(company_manpower_cost1),0) as companyManpowerCost1,
            IFNULL(SUM(company_manpower_cost2),0) as companyManpowerCost2,
            IFNULL(SUM(order_bill),0) as orderBillSum,
            IFNULL(SUM(net_profit),0) as netProfit
        FROM
            month_develop_gross_data
        WHERE
            `month` = #{month}
        GROUP BY
            bloc,
            department,
            develop_department,
            is_performance
    </select>

如上,我有一堆sum字段需要起别名,我使用MonthDevelopGrossData作为承接类

一开始我用表字段做as别名,如下,使用@TableField注释映射

 @TableField("company_manpower_cost1")
    private BigDecimal companyManpowerCost1;
思考

发现是不生效的,所以判断@TableField对自己手写的sql as是不生效的。
网上百度有个老哥说只有使用mybatisPlus自己的语法调用sql,会生效。这个暂时还没有尝试。

建议

所以建议这种需要别名的就直接一步到位,用bean里面的属性名直接承接,不要玩花活了

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值