大家帮忙看看这么一个open source的项目有价值么?
[url] http://code.google.com/p/ibear/ [/url]
一直有个想法:
大家数据库的项目做多了就会发现 写SQL是个很大的工作量,表连接的关系经常要去查数据字典或者ER图。如果ER图本身就是工程的一部分的话那该多好即便于维护又对写程序有很大的帮助。
无论是报表还是查询程序经常需要连接大量的表,连接关系写错和漏写经常会引起错误并且不容易发现,并且查询的条件经常是动态的。比如说页面上有个城市code,如果用户补填就不作为查询条件。
我希望能有这么个功能 更具上面的需求通过简单的配置 很容易写出简单的查询SQl并且能够得到装配好的Bean。
比如表关系的diagram可能存放如下,这样ER图就有了,程序可以容易的读取。
[code]
//--ER Diagram whole project maintain just one .
<relations>
<relation>
<key>
T1#T2
</key>
<fields>
<field>
fielda=fieldb
</field>
<fields>
</relation>
......................
</relationS>
[/code]
有了这样的ER图就可以自动生成select update delete 以及 import export 还可以通过一张主表导出所有相关的数据,在实施的初期很有用。
查询可以如下
select
字段 { optional
【1】如果定义了要返回的Bean的话就 以返回的Bean的property 组成select 的字段。
【2】如果定义返回的字段就返回查询表的所有字段。
【3】 也可以自定义需要查询的字段
}
表名{ 所有需要连接的表的名字}
join {optional
default lef tjoin
ER图中的链接key
}
where{
null_ignore 如果输入值是空的就不作为查询条件
null_sensitive 如果输入值是空就拿 isnull为脚尖
}
tail{
group by 等
}
[b]= what I will not do =[/b]
#1 connection and transaction manager Spring , dbUtils other framework can work for it .
#2 SQL execute ,left it to spring or other framework
[b]= What I want to do: =[/b]
As simple as to maintain a ER Diagram and generate select .update ,delete import export sql .
#1 Sometimes we need join several tables to select some datas from database,and the join relations are always fixed .So we can store the relations into a xml file (ER Diagram ).
#2 With the ER Diagram we can generate select SQL automatically without write join part and have no chance to make mistakes.
#3 Write a result handler to convert result set to one bean or multi - beans.
On some conditions SQL is dynamically generated ,especially for the where conditions.ex:On the GUI screen there are a city_code as the search condition but if user input nothing then it should not appear on the where part.
[url] http://code.google.com/p/ibear/ [/url]
一直有个想法:
大家数据库的项目做多了就会发现 写SQL是个很大的工作量,表连接的关系经常要去查数据字典或者ER图。如果ER图本身就是工程的一部分的话那该多好即便于维护又对写程序有很大的帮助。
无论是报表还是查询程序经常需要连接大量的表,连接关系写错和漏写经常会引起错误并且不容易发现,并且查询的条件经常是动态的。比如说页面上有个城市code,如果用户补填就不作为查询条件。
我希望能有这么个功能 更具上面的需求通过简单的配置 很容易写出简单的查询SQl并且能够得到装配好的Bean。
比如表关系的diagram可能存放如下,这样ER图就有了,程序可以容易的读取。
[code]
//--ER Diagram whole project maintain just one .
<relations>
<relation>
<key>
T1#T2
</key>
<fields>
<field>
fielda=fieldb
</field>
<fields>
</relation>
......................
</relationS>
[/code]
有了这样的ER图就可以自动生成select update delete 以及 import export 还可以通过一张主表导出所有相关的数据,在实施的初期很有用。
查询可以如下
select
字段 { optional
【1】如果定义了要返回的Bean的话就 以返回的Bean的property 组成select 的字段。
【2】如果定义返回的字段就返回查询表的所有字段。
【3】 也可以自定义需要查询的字段
}
表名{ 所有需要连接的表的名字}
join {optional
default lef tjoin
ER图中的链接key
}
where{
null_ignore 如果输入值是空的就不作为查询条件
null_sensitive 如果输入值是空就拿 isnull为脚尖
}
tail{
group by 等
}
[b]= what I will not do =[/b]
#1 connection and transaction manager Spring , dbUtils other framework can work for it .
#2 SQL execute ,left it to spring or other framework
[b]= What I want to do: =[/b]
As simple as to maintain a ER Diagram and generate select .update ,delete import export sql .
#1 Sometimes we need join several tables to select some datas from database,and the join relations are always fixed .So we can store the relations into a xml file (ER Diagram ).
#2 With the ER Diagram we can generate select SQL automatically without write join part and have no chance to make mistakes.
#3 Write a result handler to convert result set to one bean or multi - beans.
On some conditions SQL is dynamically generated ,especially for the where conditions.ex:On the GUI screen there are a city_code as the search condition but if user input nothing then it should not appear on the where part.
ex:
// without select xml
SelectButilder sb = new SelectButilder("T1,T2");
sb.addCondtion(a.field="#x");
sb.generate(new Object[]{"aa"})
or
// with select xml
SelectButilder sb = SQLButilderFactory.create(sample) .
sb.generate(new Object[]{"aa"})
generated sql
select a.XXX as a_xxx,b.XXX as b_xxx ..... from T1 left join T2 on fielda=fieldb where a.field1="aa"
with spring jdbctemplate or other framework help result:
[T1Bean ,T2Bean]
//optional
<select>
<name>sample</name>
<table>
T1 , T2
</table>
<where>
<null_ignore>
a.field1={#x}
<null_ignore>
</where>
</select>
//--ER Diagram whole project maintain just one .
<relations>
<relation>
<key>
T1#T2
</key>
<fields>
<field>
fielda=fieldb
</field>
<fields>
</relation>
</relationS>