@Test public void test01() { String tpl = "select * from t<#if condition??> where ${condition}</#if>"; SimpleQueryConfig cfg = new SimpleQueryConfig(tpl, null); Assert.assertEquals("select * from t", cfg.getQueryString(null)); Assert.assertNotNull(cfg.getQueryParams(null)); Assert.assertEquals(0, cfg.getQueryParams(null).size()); List<Object> params = new ArrayList<Object>(); params.add(100); cfg = new SimpleQueryConfig(tpl, params); Condition c = new EqualsCondition("id", 100); Assert.assertEquals("select * from t where id = ?", cfg.getQueryString(c)); Assert.assertNotNull(cfg.getQueryParams(null)); Assert.assertEquals(1, cfg.getQueryParams(null).size()); Assert.assertEquals(100, cfg.getQueryParams(null).get(0)); }
public String getQueryString(Condition condition) { Assert.hasText(this.queryStringTpl, "queryStringTpl is empty."); Map<String, Object> args = new HashMap<String, Object>(); if (condition != null) { String e = condition.getExpression(); if (e != null && !e.isEmpty()) args.put("condition", condition.getExpression()); } return format(this.queryStringTpl, args); }
SimpleQueryConfig extends AbstractQueryConfig { public String getQueryString(Condition condition) { Assert.hasText(this.queryStringTpl, "queryStringTpl is empty."); Map<String, Object> args = new HashMap<String, Object>(); if (condition != null) { String e = condition.getExpression(); if (e != null && !e.isEmpty()) args.put("condition", condition.getExpression()); } return format(this.queryStringTpl, args); } }
SimpleQueryConfig extends AbstractQueryConfig { public String getQueryString(Condition condition) { Assert.hasText(this.queryStringTpl, "queryStringTpl is empty."); Map<String, Object> args = new HashMap<String, Object>(); if (condition != null) { String e = condition.getExpression(); if (e != null && !e.isEmpty()) args.put("condition", condition.getExpression()); } return format(this.queryStringTpl, args); } SimpleQueryConfig();  SimpleQueryConfig(String sqlTpl, List<Object> params); }
SimpleQueryConfig extends AbstractQueryConfig { public String getQueryString(Condition condition) { Assert.hasText(this.queryStringTpl, "queryStringTpl is empty."); Map<String, Object> args = new HashMap<String, Object>(); if (condition != null) { String e = condition.getExpression(); if (e != null && !e.isEmpty()) args.put("condition", condition.getExpression()); } return format(this.queryStringTpl, args); } SimpleQueryConfig();  SimpleQueryConfig(String sqlTpl, List<Object> params); String getQueryString(Condition condition); }
SimpleQueryConfig extends AbstractQueryConfig { public String getQueryString(Condition condition) { Assert.hasText(this.queryStringTpl, "queryStringTpl is empty."); Map<String, Object> args = new HashMap<String, Object>(); if (condition != null) { String e = condition.getExpression(); if (e != null && !e.isEmpty()) args.put("condition", condition.getExpression()); } return format(this.queryStringTpl, args); } SimpleQueryConfig();  SimpleQueryConfig(String sqlTpl, List<Object> params); String getQueryString(Condition condition);  }