习惯使用jpa操作对象的方式,现在用mybatis有点不习惯。

其实是懒得写SQL,增删改查那么简单的事情你帮我做了呗,mybatis:NO。

没办法,自己搞喽!

这里主要是实现了通过代码自动生成mybatis的增删改查语句,并注册到SqlSessionFactory中,并没有生成xml文件,不生成mapper文件。只是在项目启动的时候自动生成,配置到SqlSessionFactory中,下一次启动后自动根据model自动生成相关逻辑。所以不必担心表结构修改需要改一大堆文件。使用了此方法只需要改model文件就可以了。

注意:model必须添加@Table注解,对应的列也必须添加@Column注解(javax)。

思路:

在项目启动时mybatis默认配置运行结束后添加自定义配置

@Configuration
@AutoConfigureAfter(MybatisAutoConfiguration.class)
public class MyBatisTypeMapScannerConfig {

    private Logger log = Logger.getLogger(MyBatisTypeMapScannerConfig.class);

    public MyBatisTypeMapScannerConfig(ApplicationContext applicationContext, SqlSessionFactory sqlSessionFactory) {
        

在配置中可以获取SqlSessionFactory,看到这里,已经结束了。剩下的都是不重要细节。

1.读取项目下的model(包含@table注解的类)

List<Class<?>> list = ClassUtil.getClassesWithAnnotation(Table.class);

 

2.读取model下的字段(根据@Column注解)

Map<String, Map<String, Object>> cols = ClassUtil.getColumnRelation(clas);

 

3.根据table和column信息配置resultmap,mapper

 

End;

 

代码: MyBatisTypeMapScannerConfig 

/**
 * 自动根据@Table注解和@Column注解添加mybatis中的resultmap配置,
 * 此配置生效后不需要在mapper.xml中手动添加resultmap,自动添加的resultmap的ID为类的全路径名
 * <p>
 * Title: MyBatisTypeMapScannerConfig.java
 * </p>
 * <p>
 * Description:
 * </p>
 * 
 * @author lichao1
 * @date 2018年12月4日
 * @version 1.0
 */
@Configuration
@AutoConfigureAfter(MybatisAutoConfiguration.class)
public class MyBatisTypeMapScannerConfig {

    private Logger log = Logger.getLogger(MyBatisTypeMapScannerConfig.class);

    public MyBatisTypeMapScannerConfig(ApplicationContext applicationContext, SqlSessionFactory sqlSessionFactory) {
        log.debug("自动添加resultMap");
        org.apache.ibatis.session.Configuration configuration = sqlSessionFactory.getConfiguration();
// 获取默认包下的所有包含@Table注解的类
        List<Class<?>> list = ClassUtil.getClassesWithAnnotation(Table.class);

        for (Class<?> clas : list) {
            System.out.println(clas);
            Map<String, Map<String, Object>> cols = ClassUtil.getColumnRelation(clas);
            ResultMap rm = new ResultMap.Builder(configuration, clas.getName(), clas,
                    getResultMapping(configuration, cols)).build();
            configuration.addResultMap(rm);
            List<ResultMap> resultMaps = new ArrayList<ResultMap>();
            resultMaps.add(rm);

            Table table = clas.getAnnotation(Table.class);
            String tableName = table.name();
            String allColum = getColumListString(cols); 

InputStream inputStream = createXml(clas, cols); XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, clas.getName() + ".auto", configuration.getSqlFragments()); mapperParser.parse(); } log.debug("自动添加resultMap"); } private InputStream createXml(Class<?> clas, Map<String, Map<String, Object>> cols) { StringBuilder builder = new StringBuilder(); String name = clas.getName(); Table table = clas.getAnnotation(Table.class); String tableName = table.name(); String allColum = getColumListString(cols); builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); builder.append( "<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\" >"); builder.append("<mapper namespace=\"" + name + "\" >"); Set<String> keys = cols.keySet(); String[] keyArr = new String[keys.size()]; keys.toArray(keyArr); // 查询 builder.append("<select id=\"" + name + ".select\" resultMap=\"" + name + "\" >"); builder.append("SELECT " + allColum + " FROM " + tableName + " WHERE 1=1 "); for (int i = 0; i < keyArr.length; i++) { String key = keyArr[i]; Map<String, Object> obj = cols.get(key); try { builder.append(" <if test=\"" + key + " != null\"> and " + (String) obj.get("dbname") + " = #{" + key + "} </if>"); } catch (Exception e) { log.info(obj); log.info(key); log.info(clas.getName()); } } builder.append("</select>"); // 计数 builder.append("<select id=\"" + name + ".count\" resultType=\"long\" >"); builder.append("SELECT count(*) count FROM " + tableName + " WHERE 1=1 "); for (int i = 0; i < keyArr.length; i++) { String key = keyArr[i]; Map<String, Object> obj = cols.get(key); builder.append( " <if test=\"" + key + " != null\"> and " + (String) obj.get("dbname") + " = #{" + key + "} </if>"); } builder.append("</select>"); // 删除 builder.append("<delete id=\"" + name + ".delete\" parameterType=\"java.lang.String\" >"); builder.append(" DELETE FROM " + tableName + " WHERE id =#{id} "); builder.append("</delete>"); // 更新 builder.append("<update id=\"" + name + ".update\" parameterType=\"" + name + "\" >"); builder.append("UPDATE " + tableName + " SET "); for (int i = 0; i < keyArr.length; i++) { String key = keyArr[i]; Map<String, Object> obj = cols.get(key); builder.append(" " + (String) obj.get("dbname") + " = #{" + key + "}"); if (i < (keyArr.length - 1)) { builder.append(","); } } builder.append(" WHERE id =#{id} "); builder.append("</update>"); // 插入 builder.append("<insert id=\"" + name + ".insert\" parameterType=\"" + name + "\" >"); builder.append("insert INTO " + tableName + " (" + allColum + ") VALUES"); builder.append("(" + getColumListString2(cols, "#{", "}") + ") "); builder.append("</insert>"); builder.append("</mapper>"); InputStream is = new ByteArrayInputStream(builder.toString().getBytes()); return is; } private String createListXml() { StringBuilder builder = new StringBuilder(); return builder.toString(); } /** * 获取表内字段 * * @param cols * @return */ private String getColumListString(Map<String, Map<String, Object>> cols) { return getColumListString(cols, "", ""); } private String getColumListString(Map<String, Map<String, Object>> cols, String pre, String end) { pre = pre == null ? "" : pre; end = end == null ? "" : end; Set<String> keys = cols.keySet(); String[] keyArr = new String[keys.size()]; String[] nameArr = new String[keys.size()]; keys.toArray(keyArr); for (int i = 0; i < keyArr.length; i++) { String key = keyArr[i]; Map<String, Object> obj = cols.get(key); if (((String) obj.get("dbname")).equals("update_date")) { log.info("key"); } nameArr[i] = pre + (String) obj.get("dbname") + end; } return StringUtils.join(nameArr); } private String getColumListString2(Map<String, Map<String, Object>> cols) { return getColumListString2(cols, "", ""); } private String getColumListString2(Map<String, Map<String, Object>> cols, String pre, String end) { pre = pre == null ? "" : pre; end = end == null ? "" : end; Set<String> keys = cols.keySet(); String[] keyArr = new String[keys.size()]; String[] nameArr = new String[keys.size()]; keys.toArray(keyArr); for (int i = 0; i < keyArr.length; i++) { String key = keyArr[i]; nameArr[i] = pre + key + end; } return StringUtils.join(nameArr); } /** * 根据@Column注解生成字段映射关系 * * @param configuration * @param Map<String, * Map<String, Object>> cols * @return */ private List<ResultMapping> getResultMapping(org.apache.ibatis.session.Configuration configuration, Map<String, Map<String, Object>> cols) { List<ResultMapping> resultMappings = new ArrayList<ResultMapping>(); System.out.println(cols); Set<String> keys = cols.keySet(); String[] keyArr = new String[keys.size()]; keys.toArray(keyArr); for (String key : keyArr) { String property; String column; Object javaType; Map<String, Object> map = cols.get(key); property = key; column = (String) map.get("dbname"); javaType = map.get("type"); ResultMapping mapping = new ResultMapping.Builder(configuration, property, column, (Class<?>) javaType) .build(); resultMappings.add(mapping); } return resultMappings; } }

 

ClassUtil 

/**
 * 扫描 包下的所有类
 * <p>
 * Title: ClassUtil.java
 * </p>
 * <p>
 * Description:
 * </p>
 * 
 * @author lichao1
 * @date 2018年12月3日
 * @version 1.0
 */
public class ClassUtil {

    private static Set<Class<?>> classList;
    static {
        classList = getClasses("com.esri.rest");
    }

    /**
     * 从包package中获取所有的Class
     * 
     * @param pack
     * @return
     */
    public static Set<Class<?>> getClasses(String pack) {

        // 第一个class类的集合
        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
        // 是否循环迭代
        boolean recursive = true;
        // 获取包的名字 并进行替换
        String packageName = pack;
        String packageDirName = packageName.replace('.', '/');
        // 定义一个枚举的集合 并进行循环来处理这个目录下的things
        Enumeration<URL> dirs;
        try {
            dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
            // 循环迭代下去
            while (dirs.hasMoreElements()) {
                // 获取下一个元素
                URL url = dirs.nextElement();
                // 得到协议的名称
                String protocol = url.getProtocol();
                // 如果是以文件的形式保存在服务器上
                if ("file".equals(protocol)) {
                    // System.err.println("file类型的扫描");
                    // 获取包的物理路径
                    String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
                    // 以文件的方式扫描整个包下的文件 并添加到集合中
                    findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes);
                } else if ("jar".equals(protocol)) {
                    // 如果是jar包文件
                    // 定义一个JarFile
                    // System.err.println("jar类型的扫描");
                    JarFile jar;
                    try {
                        // 获取jar
                        jar = ((JarURLConnection) url.openConnection()).getJarFile();
                        // 从此jar包 得到一个枚举类
                        Enumeration<JarEntry> entries = jar.entries();
                        // 同样的进行循环迭代
                        while (entries.hasMoreElements()) {
                            // 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
                            JarEntry entry = entries.nextElement();
                            String name = entry.getName();
                            // 如果是以/开头的
                            if (name.charAt(0) == '/') {
                                // 获取后面的字符串
                                name = name.substring(1);
                            }
                            // 如果前半部分和定义的包名相同
                            if (name.startsWith(packageDirName)) {
                                int idx = name.lastIndexOf('/');
                                // 如果以"/"结尾 是一个包
                                if (idx != -1) {
                                    // 获取包名 把"/"替换成"."
                                    packageName = name.substring(0, idx).replace('/', '.');
                                }
                                // 如果可以迭代下去 并且是一个包
                                if ((idx != -1) || recursive) {
                                    // 如果是一个.class文件 而且不是目录
                                    if (name.endsWith(".class") && !entry.isDirectory()) {
                                        // 去掉后面的".class" 获取真正的类名
                                        String className = name.substring(packageName.length() + 1, name.length() - 6);
                                        try {
                                            // 添加到classes
                                            classes.add(Class.forName(packageName + '.' + className));
                                        } catch (ClassNotFoundException e) {
                                            // log
                                            // .error("添加用户自定义视图类错误
                                            // 找不到此类的.class文件");
                                            e.printStackTrace();
                                        }
                                    }
                                }
                            }
                        }
                    } catch (IOException e) {
                        // log.error("在扫描用户定义视图时从jar包获取文件出错");
                        e.printStackTrace();
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return classes;
    }

    /**
     * 以文件的形式来获取包下的所有Class
     * 
     * @param packageName
     * @param packagePath
     * @param recursive
     * @param classes
     */
    private static void findAndAddClassesInPackageByFile(String packageName, String packagePath,
            final boolean recursive, Set<Class<?>> classes) {
        // 获取此包的目录 建立一个File
        File dir = new File(packagePath);
        // 如果不存在或者 也不是目录就直接返回
        if (!dir.exists() || !dir.isDirectory()) {
            // log.warn("用户定义包名 " + packageName + " 下没有任何文件");
            return;
        }
        // 如果存在 就获取包下的所有文件 包括目录
        File[] dirfiles = dir.listFiles(new FileFilter() {
            // 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件)
            public boolean accept(File file) {
                return (recursive && file.isDirectory()) || (file.getName().endsWith(".class"));
            }
        });
        // 循环所有文件
        for (File file : dirfiles) {
            // 如果是目录 则继续扫描
            if (file.isDirectory()) {
                findAndAddClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), recursive,
                        classes);
            } else {
                // 如果是java类文件 去掉后面的.class 只留下类名
                String className = file.getName().substring(0, file.getName().length() - 6);
                try {
                    // 添加到集合中去
                    // classes.add(Class.forName(packageName + '.' +
                    // className));
                    // 经过回复同学的提醒,这里用forName有一些不好,会触发static方法,没有使用classLoader的load干净
                    classes.add(
                            Thread.currentThread().getContextClassLoader().loadClass(packageName + '.' + className));
                } catch (ClassNotFoundException e) {
                    // log.error("添加用户自定义视图类错误 找不到此类的.class文件");
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * 根据注解查找类
     * 
     * @param annotationType
     * @return
     */
    public static List<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotationType) {
        List<Class<?>> list = new ArrayList<Class<?>>();
        Object[] ts = classList.toArray();
        for (Object t : ts) {
            Class<?> ty = (Class<?>) t;
            Object aclass = ty.getAnnotation(annotationType);
            if (aclass != null) {
                list.add(ty);
            }
        }
        return list;
    }

    /**
     * 获取类中标记Column注解的字段
     * 
     * @param clas
     * @return
     */
    public static Map<String, Map<String, Object>> getColumnRelation(Class<?> clas) {
        Map<String, Map<String, Object>> cols = new HashMap<String, Map<String, Object>>();
        // 直接标注属性
        Field field;
        Field[] fields = getAllFields(clas);// clas.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            fields[i].setAccessible(true);
        }
        for (int i = 0; i < fields.length; i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            try {
                field = fields[i];//clas.getDeclaredField(fields[i].getName());
                Column column = field.getAnnotation(Column.class);
                if (column != null) {
                    map.put("dbname", column.name());
                    map.put("length", column.length());
                    map.put("type", field.getType());
                    // System.out.println(column.name());
                    // System.out.println(column.length());
                    cols.put(field.getName(), map);
                }
            } catch (Exception e) {
            }
        }

        // 标注方法
        Method method;
        Method[] methods = getAllMethods(clas);//clas.getDeclaredMethods();
        for (int i = 0; i < methods.length; i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            try {
                method = methods[i];
                Column column = method.getAnnotation(Column.class);
                if (column != null) {
                    String filedName = method.getName();
                    boolean isGet = false;
                    // boolean isSet = false;
                    if(method.getParameterTypes().length>0){
                        // isSet = true;
                    }else{
                        isGet = true;
                    }
                    if (isGet) {
                        filedName = filedName.replaceFirst("get", "");
                        map.put("type", method.getReturnType()); 
                    } else { 
                        filedName = filedName.replaceFirst("set", "");
                        map.put("type", method.getParameterTypes()[0]); 
                    } 
                    
                    
                    filedName = filedName.substring(0, 1).toLowerCase() + filedName.substring(1);
                    map.put("dbname", column.name());
                    map.put("length", column.length());
                    cols.put(filedName, map);
                }
            } catch (SecurityException e) {
                e.printStackTrace();
            }
        }

        return cols;
    }

    /**
     * 对象转map
     * 
     * @param obj
     * @return
     */
    public static Map<String, Object> objectToMap(Object obj) {
        Map<String, Object> map = new HashMap<String, Object>();
        Class<?> clas = obj.getClass();
        Field[] fields = getAllFields(clas); // clas.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            Object value;
            try {
                value = field.get(obj);
                map.put(field.getName(), value);
            } catch (IllegalArgumentException e) {
            } catch (IllegalAccessException e) {
            }
        }
        return map;
    }

    /**
     * 
     * @param obj
     * @param ignoreNullValue
     * @return
     */
    public static Map<String, String> objectToStringMap(Object obj, boolean ignoreNullValue) {
        Map<String, String> map = new HashMap<String, String>();
        Class<?> clas = obj.getClass();
        Field[] fields = getAllFields(clas); // clas.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            String value;
            try {
                value = String.valueOf(field.get(obj));
                if(field.get(obj)==null){
                    if(!ignoreNullValue){
                        map.put(field.getName(), "");
                    }
                }else {
                    map.put(field.getName(), value);
                }
            } catch (IllegalArgumentException e) {
            } catch (IllegalAccessException e) {
            }
        }
        return map;
    }
    
    /**
     * 获取类中的所有方法,包括父类
     * @param clas
     * @return
     */
    public static Method[] getAllMethods(Class<?> clas){
        List<Method> methods = new ArrayList<Method>();
        getAllMethods(clas, methods);
        Method[] methodarr = new Method[methods.size()];
        methods.toArray(methodarr);
        return methodarr;
    }
    public static List<Method> getAllMethods(Class<?> clas, List<Method> methods){
        if(methods==null){
            methods = new ArrayList<Method>();
        }
        Method[] methodarr = clas.getDeclaredMethods();
        for (Method method : methodarr) {
            methods.add(method);
        }
        Class<?> superClas = clas.getSuperclass();
        if (superClas != null) {
            getAllMethods(superClas, methods);
        } 
        return methods;
    }

    /**
     * 获取类中的所有字段,包含父类中的字段
     * 
     * @param clas
     * @return
     */
    public static Field[] getAllFields(Class<?> clas) {
        List<Field> fields = new ArrayList<Field>();
        getAllFields(clas, fields);
        Field[] fieldarr = new Field[fields.size()];
        fields.toArray(fieldarr);
        return fieldarr;
    }

    public static List<Field> getAllFields(Class<?> clas, List<Field> fields) {
        if (fields == null) {
            fields = new ArrayList<Field>();
        }
        Field[] fields1 = clas.getDeclaredFields();
        for (Field field : fields1) {
            fields.add(field);
        }
        Class<?> superClas = clas.getSuperclass();
        if (superClas != null) {
            getAllFields(superClas, fields);
        }
        return fields;
    }

    public static void main(String[] args) {
        System.out.println(classList);
        // Object[] ts = classList.toArray();
        // for(Object t:ts){
        // Class<?> tt = (Class<?>) t;
        // System.out.println(tt);
        // }

        List<Class<?>> list = getClassesWithAnnotation(Table.class);
        for (Class<?> clas : list) {
            System.out.println(clas);
            Map<String, Map<String, Object>> cols = getColumnRelation(clas);
            System.out.println(cols);
        }
    }
}

 

 

应用 

 

CommonDaoimpl

 

/**
 * CommonDaoimpl
 * <p>
 * Title: CommonDaoimpl.java
 * </p>
 * <p>
 * Description:
 * </p>
 * 
 * @author lichao1
 * @date 2018年11月19日
 * @version 1.0
 * @param <T>
 * @param <ID>
 */
@Repository
public class CommonDaoimpl<T, ID extends Serializable> implements ICommonDao<T, ID> {

    @PersistenceContext
    private EntityManager entityManager;

    @Autowired
    public SqlSessionFactory sqlSessionFactory;

    protected <T> String getStatement(Class<T> clazz, String prefix) {
        String entityName = clazz.getSimpleName();
        if (entityName.endsWith("Model")) {
            entityName = entityName.substring(0, entityName.length() - 5);
        }
        if (entityName.endsWith("Entity")) {
            entityName = entityName.substring(0, entityName.length() - 6);
        }
        entityName = prefix + entityName;
        return entityName;
    }

    // Mybatis 查询方法, 只需要输入mapper的命名空间名称和方法名就可以实现数据库操作

    
    /**
     * 执行删除语句
     * @param statement
     * @param parameter
     * @return
     */
    public int deleteByMyBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().delete(statement, parameter);
    }

    /**
     * 执行删除语句
     * @param t
     * @param funName
     * @param parameter
     * @return
     */
    public int deleteByMyBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return deleteByMyBatis(statement, parameter);
    }
    public int deleteByMyBatis(Class<T> t, Object parameter) {
        String statement = t.getName() + "." + "delete";
        return deleteByMyBatis(statement, parameter);
    }

    /**
     * 执行查询列表
     * @param statement
     * @param parameter
     * @return
     */
    public List<T> listByMyBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().selectList(statement, parameter);
    }

    /**
     * 执行查询列表语句
     * @param t
     * @param funName
     * @param parameter
     * @return
     */
    public List<T> listByMyBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return listByMyBatis(statement, parameter);
    }
    
    public List<T> ListByMyBatis(Class<T> t, Object parameter){
        String statement = t.getName() + "." + "select";
        return listByMyBatis(statement, parameter);
    }

    /**
     * 执行插入语句
     * @param statement
     * @param parameter
     * @return
     */
    public int insertByMyBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().insert(statement, parameter);
    }

    /**
     * 执行插入语句
     * @param t
     * @param funName
     * @param parameter
     * @return
     */
    public int insertByMyBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return insertByMyBatis(statement, parameter);
    }

    /**
     * 执行选择一条记录语句
     * @param statement
     * @param parameter
     * @return
     */
    public T selectOneByMyBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().selectOne(statement, parameter);
    }

    /**
     * 执行选择一条记录语句
     * @param t
     * @param funName
     * @param parameter
     * @return
     */
    public T selectOneByMyBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return selectOneByMyBatis(statement, parameter);
    }
    
    /**
     * 计数
     * @param t
     * @param parameter
     * @return
     */
    
    public long countByMyBatis(String statement, Object parameter) {
        return (long)this.sqlSessionFactory.openSession().selectOne(statement, parameter);
    }
    
    public long countByMyBatis(Class<?> t, Object parameter){
        String statement = t.getName() + ".count";
        return countByMyBatis(statement, parameter);
    }

    /**
     * 更新数据
     * @param statement
     * @param parameter
     * @return
     */
    public int updateByMyBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().update(statement, parameter);
    }

    /**
     * 更新数据
     * @param t
     * @param funName
     * @param parameter
     * @return
     */
    public int updateByMyBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return updateByMyBatis(statement, parameter);
    }
    
    public int updateByMyBatis(Class<T> t,  Object parameter) {
        String statement = t.getName() + ".update";
        return updateByMyBatis(statement, parameter);
    }
    
    /**
     * 插入数据
     * @param statement
     * @param parameter
     * @return
     */
    public int insertByMayBatis(String statement, Object parameter) {
        return this.sqlSessionFactory.openSession().insert(statement, parameter);
    }
    
    public int insertByMayBatis(Class<T> t, String funName, Object parameter) {
        String statement = t.getName() + "." + funName;
        return this.sqlSessionFactory.openSession().insert(statement, parameter);
    }
    
    public int insertByMayBatis(Class<T> t, Object parameter) { 
        return insertByMayBatis(t,"insert", parameter);
    }

 

版权声明:本文为Leechg原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Leechg/p/10097777.html