addCondition()

condition()用来接收前端参数,如果参数值不是来自前端面是在java中构造的。需要通过org.anyline.jdbc.config.ConfigStore提供的addCondition函数用来动态添加查询条件

ConfigStore一般通过condition()返回,如:

service.query("HR_USER", condition("NM:nm").addCondition(...));
addCondition提供了多个重载,常用以下3个
//一般会生成key=value的查询条件
public ConfigStore addCondition(String key, Object value);

//通过compare来指定比较符号如于小,小于,等于,between等参考org.anyline.jdbc.config.db.SQL.COMPARE_TYPE
//需要注意的是,如果需要构造in,not int, between条件,应该通过集合形式传参
public ConfigStore addCondition(COMPARE_TYPE compare, String key, Object value);

//如果value是一个集合则生成IN条件,否则与addCondition作用相同
public ConfigStore addConditions(String key, Object value);

另外还有 
public ConfigStore addCondition(Config config);
public ConfigStore addCondition(String key, Object value, boolean overCondition, boolean overValue);
public ConfigStore addCondition(COMPARE_TYPE compare, String key, Object value, boolean overCondition, boolean overValue);
 
//这里同时提供key与var用来对应自定义SQL查询条件中的id与标签体中的变量
public ConfigStore addCondition(String key, String var, Object value);
如
<condition id="USER_AGE">AGE>{AGE_FR} AND AGE<{AGE_TO}</condition>//注意标签体中XML符号应该转义
addCondition("USER_AGE","AGE_FR","10").addCondition("USER_AGE","AGE_TO","20");

生成对应的SQL:WHERE AGE>10 AND AGE<20 

COMPARE_TYPE枚举
public static enum COMPARE_TYPE{
	EQUAL			{public int getCode(){return 10;} public String getSql(){return " = ?";} 				public String getName(){return "等于";}},
	GREAT			{public int getCode(){return 20;} public String getSql(){return " > ?";} 				public String getName(){return "大于";}},
	GREAT_EQUAL		{public int getCode(){return 21;} public String getSql(){return " >= ?";} 				public String getName(){return "大于等于";}},
	LESS			{public int getCode(){return 30;} public String getSql(){return " < ?";} 				public String getName(){return "小于";}},
	LESS_EQUAL		{public int getCode(){return 31;} public String getSql(){return " <= ?";} 				public String getName(){return "小于等于";}},
	IN				{public int getCode(){return 40;} public String getSql(){return " IN ";} 				public String getName(){return "in";}},
	LIKE			{public int getCode(){return 50;} public String getSql(){return " LIKE ";} 				public String getName(){return "%like%";}},
	LIKE_PREFIX		{public int getCode(){return 51;} public String getSql(){return " LIKE ";} 				public String getName(){return "%like";}},
	LIKE_SUBFIX		{public int getCode(){return 52;} public String getSql(){return " LIKE ";} 				public String getName(){return "like%";}},
	BETWEEN			{public int getCode(){return 80;} public String getSql(){return " BETWEEN ? AND ? ";} 	public String getName(){return "区间";}},
	NOT_EQUAL		{public int getCode(){return 110;} public String getSql(){return " != ?";} 				public String getName(){return "不等于";}},
	NOT_IN			{public int getCode(){return 140;} public String getSql(){return " NOT IN ";} 			public String getName(){return "不包含";}};
	public abstract String getName();
	public abstract String getSql();
	public abstract int getCode();
}
其他文档