zoukankan      html  css  js  c++  java
  • Atitis mybatis的功能api扩展总结 目录 1. MybatisAdvUtil 1 1.1. 根据session得到所有配置 1 1.2. Configuration1.getMappe

    Atitis mybatis的功能api扩展总结

     

    目录

    1. MybatisAdvUtil 1

    1.1. 根据session得到所有配置 1

    1.2. Configuration1.getMappedStatement(sttID) 1

    1.3. 根据语句id得到sql 1

    1.4. 得到解析后的sql 2

    1.5. getXmlPath 2

     

    1. MybatisAdvUtil

     

      1. 根据session得到所有配置

     

    SqlSession conn = MybatisUtil.getConn();

    // Configuration Configuration1 = checkSqlValds(conn);

    Configuration Configuration1=conn.getConfiguration();

     

      1. Configuration1.getMappedStatement(sttID)
      2. 根据语句id得到sql

     

    private static String getSqlBoundDefine(SqlSession conn, String sttID)  {

     

    Configuration Configuration1 = conn.getConfiguration();

    // Configuration1.addLoadedResource(resource);

     

    // Configuration1.

    MappedStatement MappedStaement1 = Configuration1.getMappedStatement(sttID);

    DynamicSqlSource DynamicSqlSource1 = (DynamicSqlSource) MappedStaement1.getSqlSource();

    // DynamicSqlSource1.

    String fldname = "rootSqlNode";

    SqlNode SqlNode1 = (SqlNode) getFldValRE(DynamicSqlSource1, "rootSqlNode");

    MixedSqlNode MixedSqlNode1 = (MixedSqlNode) SqlNode1;

    List li = (List) getFldValRE(MixedSqlNode1, "contents");

    // StaticTextSqlNode <String,TextSqlNode> <TextSqlNode>

     

    Object r = li.stream().reduce("", (s, o) -> {

     

    String string = "";

    try {

    string = getFldVal(o, "text").toString();

    } catch (NoSuchFieldException | IllegalAccessException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return s + string;

    });

    return r.toString();

    }

     

      1. 得到解析后的sql

     

    private static String getSqlBound(SqlSession conn,String sttID) {

    Configuration Configuration1=conn.getConfiguration();

     

    MappedStatement MappedStaement1= Configuration1.getMappedStatement(sttID);

    String sqlBound = MappedStaement1.getSqlSource().getBoundSql(null).getSql();

    return sqlBound;

    }

     

      1. getXmlPath

    // mapper/ veDao.xml

    private static String getXmlPath(SqlSession conn, String sttID) throws Exception {

    Configuration Configuration1 = conn.getConfiguration();

    // Configuration1.addLoadedResource(resource);

     

    // Configuration1.

    MappedStatement MappedStaement1 = Configuration1.getMappedStatement(sttID);

     

    // DynamicSqlSource1

    return MappedStaement1.getResource();

    // String sqlBound = MappedStaement1.getSqlSource().getBoundSql(null).getSql();

    // return sqlBound;

    }

  • 相关阅读:
    采用GRE隧道连接不同虚拟机上的mininet网络
    ubuntu下安装Pycharm
    Update to openvswitch 2.3.0
    安装Openvswich 2.3.0
    ubuntu安装git
    解决Vmware Vsphere中虚拟机与本地机复制粘贴问题
    windows下安装python的xlrd和xlwd安装包
    ubuntu 下NetworkX的安装和使用
    大整数乘法 python实现
    推特(Twitter)的Snowflake算法——用于生成唯一ID
  • 原文地址:https://www.cnblogs.com/attilax/p/15196944.html
Copyright © 2011-2022 走看看