1 3 package jodd.db.orm.sqlgen; 4 5 import jodd.db.orm.DbEntityDescriptor; 6 7 import java.util.Map ; 8 9 12 public class DbSqlUpdate implements DbSqlGenerator { 13 14 protected DbDynamicSqlTemplate template; 15 16 22 public DbSqlUpdate(Object object, boolean onlyExisting, Object conditions) { 23 if (onlyExisting == true) { 25 template = new DbDynamicSqlTemplate("update $T{t} set $U{t} $W{where !t.c}"); 26 } else { 27 template = new DbDynamicSqlTemplate("update $T{t} set $U{+t} $W{where !t.c}"); 28 } 29 template.use("t", object).use("c", conditions); 30 } 31 32 38 public DbSqlUpdate(Object object, boolean onlyExisting, String conditions) { 39 if (conditions == null) { 40 conditions = ""; 41 } 42 if (onlyExisting == true) { 43 template = new DbDynamicSqlTemplate("update $T{t -} set $U{t} " + conditions); 44 } else { 45 template = new DbDynamicSqlTemplate("update $T{t -} set $U{+t} " + conditions); 46 } 47 template.use("t", object); 48 } 49 50 52 public String generateQuery() { 53 return template.generateQuery(); 54 } 55 56 public Map <String , Object > getQueryParameters() { 57 return template.getQueryParameters(); 58 } 59 60 public Map <String , String []> getColumnData() { 61 return template.getColumnData(); 62 } 63 } 64 | Popular Tags |