List of usage examples for org.apache.ibatis.mapping ResultMapping.Builder ResultMapping.Builder
public Builder(Configuration configuration, String property, String column, Class<?> javaType)
From source file:com.ibatis.sqlmap.engine.builder.XmlSqlStatementParser.java
License:Apache License
private void buildSelectKeyStatement(String parentId, XNode context, boolean runStatementFirstParam) throws ClassNotFoundException { final String keyPropName = context.getStringAttribute("keyProperty"); String resultClassName = context.getStringAttribute("resultClass"); final SimpleSqlSource source = new SimpleSqlSource(mapParser, context); final boolean runStatementFirst = "post" .equalsIgnoreCase(context.getStringAttribute("type", runStatementFirstParam ? "post" : "pre")); final String keyStatementId = SqlMapSessionImpl.selectKeyIdFor(parentId); TypeHandler typeHandler = configuration.getTypeHandlerRegistry().getUnknownTypeHandler(); if (resultClassName != null) { final Class resultClass = configuration.getTypeAliasRegistry().resolveAlias(resultClassName); typeHandler = configuration.getTypeHandlerRegistry().getTypeHandler(resultClass); }//from w w w. java2s . c o m ResultMapping.Builder mappingBuilder = new ResultMapping.Builder(configuration, keyPropName, keyPropName, typeHandler); ArrayList<ResultMapping> resultMappingArrayList = new ArrayList<ResultMapping>(); resultMappingArrayList.add(mappingBuilder.build()); ResultMap.Builder resultMapBuilder = new ResultMap.Builder(configuration, keyStatementId + "ResultMap", HashMap.class, resultMappingArrayList); ArrayList<ResultMap> resultMapList = new ArrayList<ResultMap>(); resultMapList.add(resultMapBuilder.build()); MappedStatement.Builder builder = new MappedStatement.Builder(configuration, keyStatementId, source, SqlCommandType.SELECT); builder.resultMaps(resultMapList); configuration.setPostSelectKey(keyStatementId, runStatementFirst); configuration.addMappedStatement(builder.build()); }