1 // 清晰的sql语句,/~ ~/为一个语法块
2 String sql= "select * from user where 1=1 "
3 + "/~ and username = {username} ~/"
4 + "/~ and password = {password} ~/";
5
6 // filters为参数
7 Map filters = new HashMap();
8 filters.put("username", "badqiu");
9 filters.put("sex", "F");
10
11 XsqlFilterResult result = new XsqlBuilder().generateHql(sql,filters);
12
13 assertTrue(result.getAcceptedFilters().containsKey("username"));
14 assertFalse(result.getAcceptedFilters().containsKey("sex"));
15 assertEquals("select * from user where 1=1 and username = :username ", result.getXsql());
16
XsqlFilterResult为处理完返回的东西,包含两个属性xsql,acceptedFilters