GlobalConfig globalConfig; if (null != builderAssistant) { tableInfo.setCurrentNamespace(builderAssistant.getCurrentNamespace()); tableInfo.setConfigMark(builderAssistant.getConfiguration()); tableInfo.setUnderCamel(builderAssistant.getConfiguration().isMapUnderscoreToCamelCase());
private void bindMapperForNamespace() { String namespace = builderAssistant.getCurrentNamespace(); if (namespace != null) { Class<?> boundType = null; try { boundType = Resources.classForName(namespace); } catch (ClassNotFoundException e) { //ignore, bound type is not required } if (boundType != null) { if (!configuration.hasMapper(boundType)) { // Spring may not know the real resource name so we set a flag // to prevent loading again this resource from the mapper interface // look at MapperAnnotationBuilder#loadXmlResource configuration.addLoadedResource("namespace:" + namespace); configuration.addMapper(boundType); } } } }
private void bindMapperForNamespace() { String namespace = builderAssistant.getCurrentNamespace(); if (namespace != null) { Class<?> boundType = null; try { boundType = Resources.classForName(namespace); } catch (ClassNotFoundException e) { //ignore, bound type is not required } if (boundType != null) { if (!configuration.hasMapper(boundType)) { // Spring may not know the real resource name so we set a flag // to prevent loading again this resource from the mapper interface // look at MapperAnnotationBuilder#loadXmlResource configuration.addLoadedResource("namespace:" + namespace); configuration.addMapper(boundType); } } } }
private void cacheRefElement(XNode context) { if (context != null) { configuration.addCacheRef(builderAssistant.getCurrentNamespace(), context.getStringAttribute("namespace")); CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant, context.getStringAttribute("namespace")); try { cacheRefResolver.resolveCacheRef(); } catch (IncompleteElementException e) { configuration.addIncompleteCacheRef(cacheRefResolver); } } }
private void cacheRefElement(XNode context) { if (context != null) { configuration.addCacheRef(builderAssistant.getCurrentNamespace(), context.getStringAttribute("namespace")); CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant, context.getStringAttribute("namespace")); try { cacheRefResolver.resolveCacheRef(); } catch (IncompleteElementException e) { configuration.addIncompleteCacheRef(cacheRefResolver); } } }
protected void addResultMap(String id, Class<?> type, List<ResultMapping> resultMappings) { assistant.addResultMap(id, type, null, null, resultMappings, false); if (log.isDebugEnabled()) { System.out.println( "/*【" + this.assistant.getCurrentNamespace() + '.' + id + "】 */"); resultMappings.stream().forEach(System.out::println); } }
/** * 调用此方法前,需设置assistant.currentNamespace 和 methodName</br> * 若以上两个参数有一个为空(null or empty),则throw RunTimeException * * @return currentNamespace + "." + methodName */ public String getMappedStatementId() { String currentNamespace = this.assistant.getCurrentNamespace(); if (currentNamespace == null || currentNamespace.trim().equals("")) { throw new RuntimeException("currentNamespace is missing"); } if (this.method.getName() == null || this.method.getName().trim().equals("")) { throw new RuntimeException("methodName is missing"); } return currentNamespace + "." + this.method.getName(); }
protected void addMappedStatement(String id, String[] sqls, SqlCommandType sqlCommandType, Class<?> parameterType, String resultMap, Class<?> resultType, KeyGenerator keyGenerator, String keyProperty, String keyColumn) { boolean isSelect = sqlCommandType == SqlCommandType.SELECT; boolean flushCache = !isSelect; boolean useCache = isSelect; addMappedStatement(id, buildSqlSourceFromStrings(sqls, parameterType), StatementType.PREPARED, sqlCommandType, null, null, null, parameterType, resultMap, resultType, null, flushCache, useCache, false, keyGenerator, keyProperty, keyColumn, null, getLanguageDriver(), null); if (log.isDebugEnabled()) { System.out.println("/*【" + this.assistant.getCurrentNamespace() + '.' + id + "】ResultMap=" + resultMap + " */"); System.out.println((sqls.length > 1 ? sqls[1] : sqls[0]) + ";\n"); } }
private void bindMapperForNamespace() { String namespace = builderAssistant.getCurrentNamespace(); if (namespace != null) { Class boundType = null; try { boundType = Resources.classForName(namespace); } catch (ClassNotFoundException e) { //ignore, bound type is not required } if (boundType != null) { if (!configuration.hasMapper(boundType)) { configuration.addMapper(boundType); } } } }