public String process() { //@include(key;required=true|false) StringBuilder sb = new StringBuilder(chars.length); for(pos=0;pos<chars.length;pos++) { char c = chars[pos]; if(c == '@') { int mark = pos; if(nextInclude()) { String content = scanIncludeContent(); if(null != content) { SqlFragment fragment = context.getMetadata().tryGetSqlFragment(content); if(null == fragment) { throw new SqlConfigException("The included sql fragment '" + content + "' not found in sql '" + command + "', check " + command.getSource()); } String fragmentContent = fragment.getContent(); if(!Strings.containsIgnoreCase(fragmentContent, SqlIncludeProcessor.AT_INCLUDE)) { sb.append(fragmentContent); }else{ sb.append(new SqlIncludeProcessor(context,command,fragmentContent).process()); } continue; } } sb.append(Chars.substring(chars, mark, pos)); } sb.append(c); } return sb.toString(); }
protected void createMetadata(OrmContext oc, MetaApi api) { mappingDatabase(oc.getDb(), api); MappingSchema ms = ormConverter.toMappingSchema(oc, api); for(EntityMapping em : ms.getEntityMappings()) { oc.getMetadataManager().createEntity(oc, em); } //load sqls oc.getMetadataManager().loadSqls(oc); //convert sqls Map<String, SqlCommand> commands = ormConverter.toSqlCommands(oc, api); commands.forEach((k,c) -> { SqlCommand old = oc.getMetadata().tryGetSqlCommand(k); if(null != old) { log.info("The sql command '{}' from '{}' will be replaced by '{}'", k, old.getSource(), c.getSource()); oc.getMetadata().removeSqlCommand(k); } oc.getMetadata().addSqlCommand(k, c); }); }
throw new SqlConfigException("Found duplicated sql key '" + key + "', xmls : " + exists.getSource() + "," + reader.getSource());