List of usage examples for org.apache.ibatis.mapping ParameterMap.Builder ParameterMap.Builder
public Builder(Configuration configuration, String id, Class<?> type,
List<ParameterMapping> parameterMappings)
From source file:cn.org.awcp.core.mybatis.mapper.MapperTemplate.java
License:Open Source License
/** * SelectKey - ?mysqlOracle?/*from w w w. jav a 2 s . c om*/ * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityHelper.EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getSelectReturnType(ms); // defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator = null; Boolean executeBefore = getBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator(); if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); configuration.addMappedStatement(statement); MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); configuration.addKeyGenerator(keyId, keyGenerator); } // keyGenerator try { MetaObject msObject = forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", new String[] { column.getProperty() }); } catch (Exception e) { // ignore } }
From source file:com.github.abel533.mapper.MapperTemplate.java
License:Open Source License
/** * SelectKey - ?mysqlOracle?//w w w .jav a2 s . c om * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityHelper.EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getSelectReturnType(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator = new NoKeyGenerator(); Boolean executeBefore = getBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator(); SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(keyGenerator); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", int.class, new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); configuration.addMappedStatement(statement); MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); configuration.addKeyGenerator(keyId, new SelectKeyGenerator(keyStatement, executeBefore)); //keyGenerator try { MetaObject msObject = forObject(ms); msObject.setValue("keyGenerator", configuration.getKeyGenerator(keyId)); } catch (Exception e) { //ignore } }
From source file:com.github.abel533.mapperhelper.MapperTemplate.java
License:Open Source License
/** * SelectKey - ?mysqlOracle?//from w w w . ja v a 2 s . com * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityHelper.EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getSelectReturnType(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator = null; Boolean executeBefore = getBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator(); if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); configuration.addMappedStatement(statement); MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); configuration.addKeyGenerator(keyId, keyGenerator); } //keyGenerator try { MetaObject msObject = forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", new String[] { column.getProperty() }); } catch (Exception e) { //ignore } }
From source file:com.hand.hap.mybatis.mapperhelper.MapperTemplate.java
License:Open Source License
/** * SelectKey/* w w w .jav a 2 s. c o m*/ * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getEntityClass(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator; Boolean executeBefore = isBEFORE(); // mod by jessen String generator = column.getGenerator() == null ? null : column.getGenerator(); String IDENTITY = ("IDENTITY".equals(generator) || StringUtil.isEmpty(generator)) ? getIDENTITY() : generator; if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { if ("SEQUENCE".equalsIgnoreCase(IDENTITY)) { // add by jessen, sql for selectKey IDENTITY = "SELECT " + getSeqNextVal(column) + " FROM DUAL"; } SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); try { configuration.addMappedStatement(statement); } catch (Exception e) { //ignore } MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); try { configuration.addKeyGenerator(keyId, keyGenerator); } catch (Exception e) { //ignore } } //keyGenerator try { MetaObject msObject = SystemMetaObject.forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", column.getTable().getKeyProperties()); msObject.setValue("keyColumns", column.getTable().getKeyColumns()); } catch (Exception e) { //ignore } }
From source file:com.ibatis.sqlmap.engine.builder.XmlSqlStatementParser.java
License:Apache License
public void parseGeneralStatement(XNode context) { // get attributes String id = context.getStringAttribute("id"); String parameterMapName = context.getStringAttribute("parameterMap"); String parameterClassName = context.getStringAttribute("parameterClass"); String resultMapName = context.getStringAttribute("resultMap"); String resultClassName = context.getStringAttribute("resultClass"); String cacheModelName = context.getStringAttribute("cacheModel"); String resultSetType = context.getStringAttribute("resultSetType"); String fetchSize = context.getStringAttribute("fetchSize"); String timeout = context.getStringAttribute("timeout"); // 2.x -- String allowRemapping = context.getStringAttribute("remapResults"); if (context.getStringAttribute("xmlResultName") != null) { throw new UnsupportedOperationException("xmlResultName is not supported by iBATIS 3"); }// w w w . ja v a 2 s. c o m if (mapParser.getConfigParser().isUseStatementNamespaces()) { id = mapParser.applyNamespace(id); } String[] additionalResultMapNames = null; if (resultMapName != null) { additionalResultMapNames = getAllButFirstToken(resultMapName); resultMapName = getFirstToken(resultMapName); resultMapName = mapParser.applyNamespace(resultMapName); for (int i = 0; i < additionalResultMapNames.length; i++) { additionalResultMapNames[i] = mapParser.applyNamespace(additionalResultMapNames[i]); } } String[] additionalResultClassNames = null; if (resultClassName != null) { additionalResultClassNames = getAllButFirstToken(resultClassName); resultClassName = getFirstToken(resultClassName); } Class[] additionalResultClasses = null; if (additionalResultClassNames != null) { additionalResultClasses = new Class[additionalResultClassNames.length]; for (int i = 0; i < additionalResultClassNames.length; i++) { additionalResultClasses[i] = resolveClass(additionalResultClassNames[i]); } } Integer timeoutInt = timeout == null ? null : new Integer(timeout); Integer fetchSizeInt = fetchSize == null ? null : new Integer(fetchSize); // 2.x -- boolean allowRemappingBool = "true".equals(allowRemapping); SqlSource sqlSource = new SqlSourceFactory(mapParser).newSqlSourceIntance(mapParser, context); String nodeName = context.getNode().getNodeName(); SqlCommandType sqlCommandType; try { sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase()); } catch (Exception e) { sqlCommandType = SqlCommandType.UNKNOWN; } MappedStatement.Builder builder = new MappedStatement.Builder(configuration, id, sqlSource, sqlCommandType); builder.useCache(true); if (!"select".equals(context.getNode().getNodeName())) { builder.flushCacheRequired(true); } if (parameterMapName != null) { parameterMapName = mapParser.applyNamespace(parameterMapName); builder.parameterMap(configuration.getParameterMap(parameterMapName)); } else if (parameterClassName != null) { Class parameterClass = resolveClass(parameterClassName); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); if (sqlSource instanceof SimpleSqlSource) { parameterMappings = sqlSource.getBoundSql(null).getParameterMappings(); } ParameterMap.Builder parameterMapBuilder = new ParameterMap.Builder(configuration, id + "-ParameterMap", parameterClass, parameterMappings); builder.parameterMap(parameterMapBuilder.build()); } List<ResultMap> resultMaps = new ArrayList<ResultMap>(); if (resultMapName != null) { resultMaps.add(configuration.getResultMap(resultMapName)); if (additionalResultMapNames != null) { for (String additionalResultMapName : additionalResultMapNames) { resultMaps.add(configuration.getResultMap(additionalResultMapName)); } } } else if (resultClassName != null) { Class resultClass = resolveClass(resultClassName); ResultMap.Builder resultMapBuilder = new ResultMap.Builder(configuration, id + "-ResultMap", resultClass, new ArrayList<ResultMapping>()); resultMaps.add(resultMapBuilder.build()); if (additionalResultClasses != null) { for (Class additionalResultClass : additionalResultClasses) { resultMapBuilder = new ResultMap.Builder(configuration, id + "-ResultMap", additionalResultClass, new ArrayList<ResultMapping>()); resultMaps.add(resultMapBuilder.build()); } } } builder.resultMaps(resultMaps); builder.fetchSize(fetchSizeInt); builder.timeout(timeoutInt); if (cacheModelName != null) { cacheModelName = mapParser.applyNamespace(cacheModelName); Cache cache = configuration.getCache(cacheModelName); builder.cache(cache); } if (resultSetType != null) { builder.resultSetType(ResultSetType.valueOf(resultSetType)); } // allowRemappingBool -- silently ignored findAndParseSelectKey(id, context); configuration.addMappedStatement(builder.build()); }
From source file:com.noasking.mapper.mapperhelper.MapperTemplate.java
License:Open Source License
/** * SelectKey// w w w . jav a 2 s . com * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getEntityClass(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator; Boolean executeBefore = isBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator(); if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); try { configuration.addMappedStatement(statement); } catch (Exception e) { //ignore } MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); try { configuration.addKeyGenerator(keyId, keyGenerator); } catch (Exception e) { //ignore } } //keyGenerator try { MetaObject msObject = SystemMetaObject.forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", column.getTable().getKeyProperties()); msObject.setValue("keyColumns", column.getTable().getKeyColumns()); } catch (Exception e) { //ignore } }
From source file:com.sinotopia.mybatis.mapper.mapperhelper.MapperTemplate.java
License:Open Source License
/** * SelectKey/*from w w w . j av a2 s . c o m*/ * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getEntityClass(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator; Boolean executeBefore = isBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY(column) : column.getGenerator(); if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new ArrayList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new ArrayList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); try { configuration.addMappedStatement(statement); } catch (Exception e) { //ignore } MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); try { configuration.addKeyGenerator(keyId, keyGenerator); } catch (Exception e) { //ignore } } //keyGenerator try { MetaObject msObject = SystemMetaObject.forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", column.getTable().getKeyProperties()); msObject.setValue("keyColumns", column.getTable().getKeyColumns()); } catch (Exception e) { //ignore } }
From source file:message.mybatis.common.mapper.MapperTemplate.java
License:Open Source License
/** * SelectKey - ?mysqlOracle?/* w w w .j ava2 s . co m*/ * * @param ms * @param column */ protected void newSelectKeyMappedStatement(MappedStatement ms, EntityHelper.EntityColumn column) { String keyId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX; if (ms.getConfiguration().hasKeyGenerator(keyId)) { return; } Class<?> entityClass = getSelectReturnType(ms); //defaults Configuration configuration = ms.getConfiguration(); KeyGenerator keyGenerator; Boolean executeBefore = getBEFORE(); String IDENTITY = (column.getGenerator() == null || column.getGenerator().equals("")) ? getIDENTITY() : column.getGenerator(); if (IDENTITY.equalsIgnoreCase("JDBC")) { keyGenerator = new Jdbc3KeyGenerator(); } else { SqlSource sqlSource = new RawSqlSource(configuration, IDENTITY, entityClass); MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, keyId, sqlSource, SqlCommandType.SELECT); statementBuilder.resource(ms.getResource()); statementBuilder.fetchSize(null); statementBuilder.statementType(StatementType.STATEMENT); statementBuilder.keyGenerator(new NoKeyGenerator()); statementBuilder.keyProperty(column.getProperty()); statementBuilder.keyColumn(null); statementBuilder.databaseId(null); statementBuilder.lang(configuration.getDefaultScriptingLanuageInstance()); statementBuilder.resultOrdered(false); statementBuilder.resulSets(null); statementBuilder.timeout(configuration.getDefaultStatementTimeout()); List<ParameterMapping> parameterMappings = new LinkedList<ParameterMapping>(); ParameterMap.Builder inlineParameterMapBuilder = new ParameterMap.Builder(configuration, statementBuilder.id() + "-Inline", entityClass, parameterMappings); statementBuilder.parameterMap(inlineParameterMapBuilder.build()); List<ResultMap> resultMaps = new LinkedList<ResultMap>(); ResultMap.Builder inlineResultMapBuilder = new ResultMap.Builder(configuration, statementBuilder.id() + "-Inline", column.getJavaType(), new LinkedList<ResultMapping>(), null); resultMaps.add(inlineResultMapBuilder.build()); statementBuilder.resultMaps(resultMaps); statementBuilder.resultSetType(null); statementBuilder.flushCacheRequired(false); statementBuilder.useCache(false); statementBuilder.cache(null); MappedStatement statement = statementBuilder.build(); try { configuration.addMappedStatement(statement); } catch (Exception e) { //ignore } MappedStatement keyStatement = configuration.getMappedStatement(keyId, false); keyGenerator = new SelectKeyGenerator(keyStatement, executeBefore); try { configuration.addKeyGenerator(keyId, keyGenerator); } catch (Exception e) { //ignore } } //keyGenerator try { MetaObject msObject = SystemMetaObject.forObject(ms); msObject.setValue("keyGenerator", keyGenerator); msObject.setValue("keyProperties", column.getTable().getKeyProperties()); msObject.setValue("keyColumns", column.getTable().getKeyColumns()); } catch (Exception e) { //ignore } }