Example usage for org.apache.ibatis.mapping ResultFlag ID

List of usage examples for org.apache.ibatis.mapping ResultFlag ID

Introduction

In this page you can find the example usage for org.apache.ibatis.mapping ResultFlag ID.

Prototype

ResultFlag ID

To view the source code for org.apache.ibatis.mapping ResultFlag ID.

Click Source Link

Usage

From source file:com.baomidou.mybatisplus.MybatisMapperAnnotationBuilder.java

License:Apache License

private void applyResults(Result[] results, Class<?> resultType, List<ResultMapping> resultMappings) {
    for (Result result : results) {
        List<ResultFlag> flags = new ArrayList<>();
        if (result.id()) {
            flags.add(ResultFlag.ID);
        }/*from w w  w .jav a2s  .com*/
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) ((result
                .typeHandler() == UnknownTypeHandler.class) ? null : result.typeHandler());
        ResultMapping resultMapping = assistant.buildResultMapping(resultType, nullOrEmpty(result.property()),
                nullOrEmpty(result.column()), result.javaType() == void.class ? null : result.javaType(),
                result.jdbcType() == JdbcType.UNDEFINED ? null : result.jdbcType(),
                hasNestedSelect(result) ? nestedSelectId(result) : null, null, null, null, typeHandler, flags,
                null, null, isLazy(result));
        resultMappings.add(resultMapping);
    }
}

From source file:com.baomidou.mybatisplus.MybatisMapperAnnotationBuilder.java

License:Apache License

private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMapping> resultMappings) {
    for (Arg arg : args) {
        List<ResultFlag> flags = new ArrayList<>();
        flags.add(ResultFlag.CONSTRUCTOR);
        if (arg.id()) {
            flags.add(ResultFlag.ID);
        }//  w  w w.j  a v a2 s  . c  o m
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) (arg
                .typeHandler() == UnknownTypeHandler.class ? null : arg.typeHandler());
        ResultMapping resultMapping = assistant.buildResultMapping(resultType, nullOrEmpty(arg.name()),
                nullOrEmpty(arg.column()), arg.javaType() == void.class ? null : arg.javaType(),
                arg.jdbcType() == JdbcType.UNDEFINED ? null : arg.jdbcType(), nullOrEmpty(arg.select()),
                nullOrEmpty(arg.resultMap()), null, null, typeHandler, flags, null, null, false);
        resultMappings.add(resultMapping);
    }
}

From source file:com.baomidou.mybatisplus.MybatisXMLMapperBuilder.java

License:Apache License

private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings)
        throws Exception {
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
    String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType",
            resultMapNode.getStringAttribute("resultType", resultMapNode.getStringAttribute("javaType"))));
    String extend = resultMapNode.getStringAttribute("extends");
    Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
    Class<?> typeClass = resolveClass(type);
    Discriminator discriminator = null;/*from  w  ww  . ja  v a2 s.c o  m*/
    List<ResultMapping> resultMappings = new ArrayList<>();
    resultMappings.addAll(additionalResultMappings);
    List<XNode> resultChildren = resultMapNode.getChildren();
    for (XNode resultChild : resultChildren) {
        if ("constructor".equals(resultChild.getName())) {
            processConstructorElement(resultChild, typeClass, resultMappings);
        } else if ("discriminator".equals(resultChild.getName())) {
            discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
        } else {
            List<ResultFlag> flags = new ArrayList<>();
            if ("id".equals(resultChild.getName())) {
                flags.add(ResultFlag.ID);
            }
            resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
        }
    }
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend,
            discriminator, resultMappings, autoMapping);
    try {
        return resultMapResolver.resolve();
    } catch (IncompleteElementException e) {
        configuration.addIncompleteResultMap(resultMapResolver);
        throw e;
    }
}

From source file:com.baomidou.mybatisplus.MybatisXMLMapperBuilder.java

License:Apache License

private void processConstructorElement(XNode resultChild, Class<?> resultType,
        List<ResultMapping> resultMappings) throws Exception {
    List<XNode> argChildren = resultChild.getChildren();
    for (XNode argChild : argChildren) {
        List<ResultFlag> flags = new ArrayList<>();
        flags.add(ResultFlag.CONSTRUCTOR);
        if ("idArg".equals(argChild.getName())) {
            flags.add(ResultFlag.ID);
        }/*www  .  j a va2s.  c  om*/
        resultMappings.add(buildResultMappingFromContext(argChild, resultType, flags));
    }
}

From source file:com.dmm.framework.basedb.apache.ibatis.builder.xml.XMLMapperBuilder.java

License:Apache License

private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings)
        throws Exception {
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
    String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType",
            resultMapNode.getStringAttribute("resultType", resultMapNode.getStringAttribute("javaType"))));
    String extend = resultMapNode.getStringAttribute("extends");
    Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
    Class<?> typeClass = resolveClass(type);
    Discriminator discriminator = null;//from   w  ww.j a  va2s .  co  m
    List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
    resultMappings.addAll(additionalResultMappings);
    List<XNode> resultChildren = resultMapNode.getChildren();
    for (XNode resultChild : resultChildren) {
        if ("constructor".equals(resultChild.getName())) {
            processConstructorElement(resultChild, typeClass, resultMappings);
        } else if ("discriminator".equals(resultChild.getName())) {
            discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
        } else {
            ArrayList<ResultFlag> flags = new ArrayList<ResultFlag>();
            if ("id".equals(resultChild.getName())) {
                flags.add(ResultFlag.ID);
            }
            resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
        }
    }
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend,
            discriminator, resultMappings, autoMapping);
    try {
        return resultMapResolver.resolve();
    } catch (IncompleteElementException e) {
        configuration.addIncompleteResultMap(resultMapResolver);
        throw e;
    }
}

From source file:com.dmm.framework.basedb.apache.ibatis.builder.xml.XMLMapperBuilder.java

License:Apache License

private void processConstructorElement(XNode resultChild, Class<?> resultType,
        List<ResultMapping> resultMappings) throws Exception {
    List<XNode> argChildren = resultChild.getChildren();
    for (XNode argChild : argChildren) {
        ArrayList<ResultFlag> flags = new ArrayList<ResultFlag>();
        flags.add(ResultFlag.CONSTRUCTOR);
        if ("idArg".equals(argChild.getName())) {
            flags.add(ResultFlag.ID);
        }//from  w  ww  .ja v  a2s.  c o  m
        resultMappings.add(buildResultMappingFromContext(argChild, resultType, flags));
    }
}

From source file:com.hand.hap.mybatis.entity.EntityTable.java

License:Open Source License

/**
 * ??resultMap/* ww  w . j a va  2  s.  co m*/
 *
 * @param configuration
 * @return
 */
public ResultMap getResultMap(Configuration configuration) {
    if (this.resultMap != null) {
        return this.resultMap;
    }
    if (entityClassColumns == null || entityClassColumns.size() == 0) {
        return null;
    }
    List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
    for (EntityColumn entityColumn : entityClassColumns) {
        ResultMapping.Builder builder = new ResultMapping.Builder(configuration, entityColumn.getProperty(),
                entityColumn.getColumn(), entityColumn.getJavaType());
        if (entityColumn.getJdbcType() != null) {
            builder.jdbcType(entityColumn.getJdbcType());
        }
        if (entityColumn.getTypeHandler() != null) {
            try {
                builder.typeHandler(entityColumn.getTypeHandler().newInstance());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        List<ResultFlag> flags = new ArrayList<ResultFlag>();
        if (entityColumn.isId()) {
            flags.add(ResultFlag.ID);
        }
        builder.flags(flags);
        resultMappings.add(builder.build());
    }
    ResultMap.Builder builder = new ResultMap.Builder(configuration, "BaseMapperResultMap", this.entityClass,
            resultMappings, true);
    this.resultMap = builder.build();
    return this.resultMap;
}

From source file:com.mybatisX.core.MybatisMapperAnnotationBuilder.java

License:Apache License

private void applyResults(Result[] results, Class<?> resultType, List<ResultMapping> resultMappings) {
    for (Result result : results) {
        List<ResultFlag> flags = new ArrayList<ResultFlag>();
        if (result.id()) {
            flags.add(ResultFlag.ID);
        }//from   ww  w.  j a va2  s .co m
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) ((result
                .typeHandler() == UnknownTypeHandler.class) ? null : result.typeHandler());
        ResultMapping resultMapping = assistant.buildResultMapping(resultType, nullOrEmpty(result.property()),
                nullOrEmpty(result.column()), result.javaType() == void.class ? null : result.javaType(),
                result.jdbcType() == JdbcType.UNDEFINED ? null : result.jdbcType(),
                hasNestedSelect(result) ? nestedSelectId(result) : null, null, null, null, typeHandler, flags,
                null, null, isLazy(result));
        resultMappings.add(resultMapping);
    }
}

From source file:com.mybatisX.core.MybatisMapperAnnotationBuilder.java

License:Apache License

private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMapping> resultMappings) {
    for (Arg arg : args) {
        List<ResultFlag> flags = new ArrayList<ResultFlag>();
        flags.add(ResultFlag.CONSTRUCTOR);
        if (arg.id()) {
            flags.add(ResultFlag.ID);
        }/* ww w .j ava2 s. c o  m*/
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) (arg
                .typeHandler() == UnknownTypeHandler.class ? null : arg.typeHandler());
        ResultMapping resultMapping = assistant.buildResultMapping(resultType, null, nullOrEmpty(arg.column()),
                arg.javaType() == void.class ? null : arg.javaType(),
                arg.jdbcType() == JdbcType.UNDEFINED ? null : arg.jdbcType(), nullOrEmpty(arg.select()),
                nullOrEmpty(arg.resultMap()), null, null, typeHandler, flags, null, null, false);
        resultMappings.add(resultMapping);
    }
}

From source file:com.mybatisX.core.MybatisXMLMapperBuilder.java

License:Apache License

private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings)
        throws Exception {
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
    String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType",
            resultMapNode.getStringAttribute("resultType", resultMapNode.getStringAttribute("javaType"))));
    String extend = resultMapNode.getStringAttribute("extends");
    Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
    Class<?> typeClass = resolveClass(type);
    Discriminator discriminator = null;/*from ww  w.j a v  a 2s  . com*/
    List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
    resultMappings.addAll(additionalResultMappings);
    List<XNode> resultChildren = resultMapNode.getChildren();
    for (XNode resultChild : resultChildren) {
        if ("constructor".equals(resultChild.getName())) {
            processConstructorElement(resultChild, typeClass, resultMappings);
        } else if ("discriminator".equals(resultChild.getName())) {
            discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
        } else {
            List<ResultFlag> flags = new ArrayList<ResultFlag>();
            if ("id".equals(resultChild.getName())) {
                flags.add(ResultFlag.ID);
            }
            resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
        }
    }
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend,
            discriminator, resultMappings, autoMapping);
    try {
        return resultMapResolver.resolve();
    } catch (IncompleteElementException e) {
        configuration.addIncompleteResultMap(resultMapResolver);
        throw e;
    }
}