@Test public void build() throws Exception { List<String> properties = Lists.newArrayList("id", "userName", "userAge"); List<String> columns = Lists.newArrayList("id", "user_name", "user_age"); CommonUpdateBuilder b = new CommonUpdateBuilder("id", properties, columns); assertThat(b.buildSql(), equalTo("update #table set user_name = :userName, user_age = :userAge where id = :id")); }
@Override public String buildSql() { List<String> exps = new ArrayList<String>(); for (int i = 0; i < properties.size(); i++) { String exp = columns.get(i) + " = :" + properties.get(i); exps.add(exp); } String s1 = Joiner.on(", ").join(exps); String s2 = columnId + " = :" + propertyId; return String.format(SQL_TEMPLATE, s1, s2); }
CommonUpdateBuilder extends AbstractCommonBuilder { @Override public String buildSql() { List<String> exps = new ArrayList<String>(); for (int i = 0; i < properties.size(); i++) { String exp = columns.get(i) + " = :" + properties.get(i); exps.add(exp); } String s1 = Joiner.on(", ").join(exps); String s2 = columnId + " = :" + propertyId; return String.format(SQL_TEMPLATE, s1, s2); } }
CommonUpdateBuilder extends AbstractCommonBuilder { @Override public String buildSql() { List<String> exps = new ArrayList<String>(); for (int i = 0; i < properties.size(); i++) { String exp = columns.get(i) + " = :" + properties.get(i); exps.add(exp); } String s1 = Joiner.on(", ").join(exps); String s2 = columnId + " = :" + propertyId; return String.format(SQL_TEMPLATE, s1, s2); } CommonUpdateBuilder(String propId, List<String> props,
                             List<String> cols); }
CommonUpdateBuilder extends AbstractCommonBuilder { @Override public String buildSql() { List<String> exps = new ArrayList<String>(); for (int i = 0; i < properties.size(); i++) { String exp = columns.get(i) + " = :" + properties.get(i); exps.add(exp); } String s1 = Joiner.on(", ").join(exps); String s2 = columnId + " = :" + propertyId; return String.format(SQL_TEMPLATE, s1, s2); } CommonUpdateBuilder(String propId, List<String> props,
                             List<String> cols); @Override String buildSql(); }
CommonUpdateBuilder extends AbstractCommonBuilder { @Override public String buildSql() { List<String> exps = new ArrayList<String>(); for (int i = 0; i < properties.size(); i++) { String exp = columns.get(i) + " = :" + properties.get(i); exps.add(exp); } String s1 = Joiner.on(", ").join(exps); String s2 = columnId + " = :" + propertyId; return String.format(SQL_TEMPLATE, s1, s2); } CommonUpdateBuilder(String propId, List<String> props,
                             List<String> cols); @Override String buildSql();  }