Example usage for org.apache.ibatis.mapping ResultMap hasNestedResultMaps

List of usage examples for org.apache.ibatis.mapping ResultMap hasNestedResultMaps

Introduction

In this page you can find the example usage for org.apache.ibatis.mapping ResultMap hasNestedResultMaps.

Prototype

boolean hasNestedResultMaps

To view the source code for org.apache.ibatis.mapping ResultMap hasNestedResultMaps.

Click Source Link

Usage

From source file:com.dmm.framework.basedb.apache.ibatis.session.Configuration.java

License:Apache License

protected void checkGloballyForDiscriminatedNestedResultMaps(ResultMap rm) {
    if (rm.hasNestedResultMaps()) {
        for (Map.Entry<String, ResultMap> entry : resultMaps.entrySet()) {
            Object value = entry.getValue();
            if (value instanceof ResultMap) {
                ResultMap entryResultMap = (ResultMap) value;
                if (!entryResultMap.hasNestedResultMaps() && entryResultMap.getDiscriminator() != null) {
                    Collection<String> discriminatedResultMapNames = entryResultMap.getDiscriminator()
                            .getDiscriminatorMap().values();
                    if (discriminatedResultMapNames.contains(rm.getId())) {
                        entryResultMap.forceNestedResultMaps();
                    }//from  ww w. ja  v  a  2  s . c om
                }
            }
        }
    }
}

From source file:com.dmm.framework.basedb.apache.ibatis.session.Configuration.java

License:Apache License

protected void checkLocallyForDiscriminatedNestedResultMaps(ResultMap rm) {
    if (!rm.hasNestedResultMaps() && rm.getDiscriminator() != null) {
        for (Map.Entry<String, String> entry : rm.getDiscriminator().getDiscriminatorMap().entrySet()) {
            String discriminatedResultMapName = entry.getValue();
            if (hasResultMap(discriminatedResultMapName)) {
                ResultMap discriminatedResultMap = resultMaps.get(discriminatedResultMapName);
                if (discriminatedResultMap.hasNestedResultMaps()) {
                    rm.forceNestedResultMaps();
                    break;
                }//from   ww w  .j a va 2  s.c o  m
            }
        }
    }
}

From source file:com.github.abel533.mapper.MapperHelper.java

License:Open Source License

/**
 * ?Key?/*from  w  w  w.j av a  2s . c o m*/
 *
 * @param result
 * @param ms
 */
public void cameHumpMap(Object result, MappedStatement ms) {
    ResultMap resultMap = ms.getResultMaps().get(0);
    Class<?> type = resultMap.getType();
    //?typeMap,???resultMap,???
    if (result instanceof List && ((List) result).size() > 0 && Map.class.isAssignableFrom(type)
            && !resultMap.hasNestedQueries() && !resultMap.hasNestedResultMaps()) {
        List resultList = (List) result;
        //1.resultType
        if (resultMap.getId().endsWith("-Inline")) {
            for (Object re : resultList) {
                processMap((Map) re);
            }
        } else {//2.resultMap
            for (Object re : resultList) {
                processMap((Map) re, resultMap.getResultMappings());
            }
        }
    }
}

From source file:com.yunmel.syncretic.core.CameHumpInterceptor.java

License:Apache License

public Object intercept(Invocation invocation) throws Throwable {
    // ??//from   w w  w . j a v a 2s.  c  om
    Object result = invocation.proceed();
    MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
    ResultMap resultMap = mappedStatement.getResultMaps().get(0);
    Class<?> type = resultMap.getType();
    // ?typeMap,???resultMap,???
    if (((List) result).size() > 0 && Map.class.isAssignableFrom(type) && !resultMap.hasNestedQueries()
            && !resultMap.hasNestedResultMaps()) {
        List resultList = (List) result;
        // 1.resultType
        if (resultMap.getId().endsWith(RESULT_TYPE)) {
            for (Object re : resultList) {
                if (re == null)
                    continue;
                processMap((Map) re);
            }
        } else {// 2.resultMap
            for (Object re : resultList) {
                processMap((Map) re, resultMap.getResultMappings());
            }
        }
    }
    return result;
}