All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.shenjia.mybatis.generator.plugins.MapperXmlOverwritePlugin Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
/**
 * Copyright 2015-2016 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 org.shenjia.mybatis.generator.plugins;

import java.lang.reflect.Field;
import java.util.List;

import org.mybatis.generator.api.GeneratedXmlFile;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;

/**
 * 
 * @author json
 *
 */
public class MapperXmlOverwritePlugin extends PluginAdapter {

	public boolean validate(List warnings) {
		return true;
	}

	@Override
	public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
		System.err.println("Before GXF is mergeable:" + sqlMap.isMergeable());
		try {
			Field field = sqlMap.getClass().getDeclaredField("isMergeable");
			field.setAccessible(true);
			field.setBoolean(sqlMap, false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.err.println("After GXF is mergeable:" + sqlMap.isMergeable());
		return true;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy