Java Code Examples for org.apache.ibatis.session.Configuration#getMappedStatements()

The following examples show how to use org.apache.ibatis.session.Configuration#getMappedStatements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapperHelper.java    From tk-mybatis with MIT License 6 votes vote down vote up
/**
 * 配置指定的接口
 *
 * @param configuration
 * @param mapperInterface
 */
public void processConfiguration(Configuration configuration, Class<?> mapperInterface) {
    String prefix;
    if (mapperInterface != null) {
        prefix = mapperInterface.getCanonicalName();
    } else {
        prefix = "";
    }
    for (Object object : new ArrayList<Object>(configuration.getMappedStatements())) {
        if (object instanceof MappedStatement) {
            MappedStatement ms = (MappedStatement) object;
            if (ms.getId().startsWith(prefix) && isMapperMethod(ms.getId())) {
                if (ms.getSqlSource() instanceof ProviderSqlSource) {
                    setSqlSource(ms);
                }
            }
        }
    }
}
 
Example 2
Source File: MapperHelperForSharding.java    From tsharding with MIT License 6 votes vote down vote up
/**
 * 处理configuration中全部的MappedStatement
 *
 * @param configuration
 */
public void processConfiguration(Configuration configuration) {
    Collection<MappedStatement> collection = configuration.getMappedStatements();
    // 防止反复处理一个
    if (collectionSet.contains(collection)) {
        return;
    } else {
        collectionSet.add(collection);
    }

    Collection<MappedStatement> tmpCollection = new HashSet<>();
    tmpCollection.addAll(collection);

    Iterator<MappedStatement> iterator = tmpCollection.iterator();
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof MappedStatement) {
            MappedStatement ms = (MappedStatement) object;
            if (isMapperMethod(ms.getId())) {
                setSqlSource(ms, configuration);
            }
        }
    }
}
 
Example 3
Source File: MapperHelper.java    From Mapper with MIT License 6 votes vote down vote up
/**
 * 配置指定的接口
 *
 * @param configuration
 * @param mapperInterface
 */
public void processConfiguration(Configuration configuration, Class<?> mapperInterface) {
    String prefix;
    if (mapperInterface != null) {
        prefix = mapperInterface.getCanonicalName();
    } else {
        prefix = "";
    }
    for (Object object : new ArrayList<Object>(configuration.getMappedStatements())) {
        if (object instanceof MappedStatement) {
            MappedStatement ms = (MappedStatement) object;
            if (ms.getId().startsWith(prefix)) {
                processMappedStatement(ms);
            }
        }
    }
}