Java Code Examples for org.apache.ibatis.mapping.ResultMap#getConstructorResultMappings()
The following examples show how to use
org.apache.ibatis.mapping.ResultMap#getConstructorResultMappings() .
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: DefaultResultSetHandler.java From mybaties with Apache License 2.0 | 6 votes |
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix) throws SQLException { //得到result type final Class<?> resultType = resultMap.getType(); final MetaClass metaType = MetaClass.forClass(resultType); final List<ResultMapping> constructorMappings = resultMap.getConstructorResultMappings(); if (typeHandlerRegistry.hasTypeHandler(resultType)) { //基本型 return createPrimitiveResultObject(rsw, resultMap, columnPrefix); } else if (!constructorMappings.isEmpty()) { //有参数的构造函数 return createParameterizedResultObject(rsw, resultType, constructorMappings, constructorArgTypes, constructorArgs, columnPrefix); } else if (resultType.isInterface() || metaType.hasDefaultConstructor()) { //普通bean类型 return objectFactory.create(resultType); } else if (shouldApplyAutomaticMappings(resultMap, false)) { //自动映射 return createByConstructorSignature(rsw, resultType, constructorArgTypes, constructorArgs, columnPrefix); } throw new ExecutorException("Do not know how to create an instance of " + resultType); }
Example 2
Source File: DefaultResultSetHandler.java From mybatis with Apache License 2.0 | 6 votes |
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix) throws SQLException { //得到result type final Class<?> resultType = resultMap.getType(); final MetaClass metaType = MetaClass.forClass(resultType); final List<ResultMapping> constructorMappings = resultMap.getConstructorResultMappings(); if (typeHandlerRegistry.hasTypeHandler(resultType)) { //基本型 return createPrimitiveResultObject(rsw, resultMap, columnPrefix); } else if (!constructorMappings.isEmpty()) { //有参数的构造函数 return createParameterizedResultObject(rsw, resultType, constructorMappings, constructorArgTypes, constructorArgs, columnPrefix); } else if (resultType.isInterface() || metaType.hasDefaultConstructor()) { //普通bean类型 return objectFactory.create(resultType); } else if (shouldApplyAutomaticMappings(resultMap, false)) { //自动映射 return createByConstructorSignature(rsw, resultType, constructorArgTypes, constructorArgs, columnPrefix); } throw new ExecutorException("Do not know how to create an instance of " + resultType); }