com.viiyue.plugins.mybatis.scripting.MyBatisMapperBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-mapper Show documentation
Show all versions of mybatis-mapper Show documentation
Mybatis generic mapper plugin for solving most basic operations,
simplifying sql syntax and improving dynamic execution efficiency
/**
* Copyright (C) 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.viiyue.plugins.mybatis.scripting;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.ibatis.builder.annotation.ProviderSqlSource;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.session.Configuration;
import com.viiyue.plugins.mybatis.mapper.Marker;
import com.viiyue.plugins.mybatis.scripting.parser.MappedStatementRegistry;
import com.viiyue.plugins.mybatis.utils.BuilderUtil;
import com.viiyue.plugins.mybatis.utils.ClassUtil;
import com.viiyue.plugins.mybatis.utils.GenericTypeUtil;
/**
* Mybatis mapper refactors the build object
*
* @author tangxbai
* @since 1.1.0
* @see MappedStatementRegistry
*/
public final class MyBatisMapperBuilder {
public static final Class> marker = Marker.class;
public static final MappedStatementRegistry registry = MappedStatementRegistry.instance();
/**
* Selective refactoring of SQL sources loaded in mybatis
*
* @param configuration mybatis core configuration
* @return the restructured configuration object
*/
public Configuration refactoring( Configuration configuration ) {
// Status check
// If the resource is recycled, it means that the whole operation
// has been completed and no further operations are required.
registry.statusCheck();
// Why do I need to copy a copy object here?
// Because the statement may be added to the MappedStatement later,
// if you do not copy a backup, adding an object in the loop will report
// java.util.ConcurrentModificationException
Collection statements = configuration.getMappedStatements();
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy