应用程序获取Mybatis中配置的执行SQL

获取到Mybatis中配置的具体SQL,而且是在程序执行时已经将参数替换完之后的完整的SQL。
举个例子,sqlMap中配置了如下sql:




    
        and issueId = ${issueId}
    
    
        and orderId = ${orderId}
    
    
        and awardStatus = ${awardStatus}
    
    
        and settleStatus = ${settleStatus}
    
    
        and buyTime >= '${buyTimeStart}'
    
    
        and buyTime <= '${buyTimeEnd}'
    
    and orderStatus = 10
    AND yn = 1

获取到的 mybatis 执行的sql为:

  select * from lottery_order_es_index where orderId=100000 and orderStatus = 10 and yn=1

核心代码为:

SqlSessionFactory.getConfiguration().getMappedStatement("TreasureOrder.queryVenderDzDetailTotalFee").getBoundSql(map).getSql();

你可能感兴趣的:(技术实践)