PDA

View Full Version : SQL Dynamic Packaging Tools



Spring0105
12-17-2009, 09:05 AM
When you use jdbc to operate directly in the program,the dynamic assemble of the sql is always a troublesome thing.Former days I have been studied on ibatis and i found that example which is produced by its code producing tool iBATOR actually is a good aql assemble.So I revised it.

Usage:

Java code
BaseSelector select = new BaseSelector();
select.setCommand("select from user ");
select.createCriteria().andEqualTo("org_code", "YZ1201")
.andGreaterThanOrEqualTo("day_code", "2009-01-01")
.andLessThanOrEqualTo("day_code", "2009-03-31");

BaseSelector select = new BaseSelector();
select.setCommand("select from user ");
select.createCriteria().andEqualTo("org_code", "YZ1201")
.andGreaterThanOrEqualTo("day_code", "2009-01-01")
.andLessThanOrEqualTo("day_code", "2009-03-31");
use select.toSql() to outlet
Java code
select from user where org_code = 'YZ1201' and day_code >= '2009-01-01' and day_code <= '2009-03-31'

select from user where org_code = 'YZ1201' and day_code >= '2009-01-01' and day_code <= '2009-03-31'