querymethods.QueryMethodsHelper Maven / Gradle / Ivy
package querymethods;
import static org.apache.ibatis.mapping.SqlCommandType.DELETE;
import static org.apache.ibatis.mapping.SqlCommandType.SELECT;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.builder.annotation.ProviderSqlSource;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.scripting.xmltags.DynamicSqlSource;
import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
import org.apache.ibatis.session.Configuration;
import querymethods.util.SqlUtil;
/**
* 查询方法帮助类,通过方法名称动态的生成sql
*
* @author OYGD
*
*/
public class QueryMethodsHelper {
protected final static Log logger = LogFactory.getLog(QueryMethodsHelper.class);
private QueryMethodsHelper() {}
private static final Map queryMethod = new HashMap<>();
private static final Map deleteMethod = new HashMap<>();
public static boolean isQueryMethods(String msId) {
return queryMethod.containsKey(msId);
}
public static boolean isDeleteMethods(String msId) {
return deleteMethod.containsKey(msId);
}
/**
* 对已经注册的Mapper文件做处理,如果方法上使用了@Select("")注册并且sql为空字符串时就会动态创建sql
* 处理configuration中全部的MappedStatement
*
* @param configuration
* @param mapperHelper
*/
public static void processConfiguration(Configuration configuration) {
processConfiguration(configuration, null);
}
/**
* 配置指定的接口
*
* @param configuration
* @param mapperInterface
*/
public static void processConfiguration(Configuration configuration, Class> mapperInterface) {
String prefix;
if (mapperInterface != null) {
prefix = mapperInterface.getCanonicalName();
} else {
prefix = "";
}
for (Object object : new ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy