- 授权协议: BSD
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://ibeetl.com
- 软件文档: http://ibeetl.com/guide/#beetlsql
软件介绍
BeetlSQL 是一个全功能 DAO 工具,同时具有 Hibernate 优点 & Mybatis 优点功能,适用于承认以 SQL 为中心,同时又需求工具能自动能生成大量常用的 SQL 的应用。
BeetlSQL介绍
派别:SQL为中心
* 强化SQL管理,通过md文件管理sql,使用Beetl模板编写复杂sql
* 简单SQL可以通过Query类链式API完成
* 内置常见增删改查功能,节省项目50%工作量
* 全面支持跨数据库平台
* 支持一对一,一对多等常见的ORM映射
* 其他
* 具备代码生成功能
* 主从支持
* 支持Interceptor,如Debug,Cache等
内置增删改查
void insert(T entity);
int updateById(T entity);
int updateTemplateById(T entity);
int deleteById(Object key);
T unique(Object key);
T single(Object key);
T lock(Object key);
List<T> all();
List<T> template(T entity);
<T> T templateOne(T entity);
List<T> execute(String sql,Object... args);
....等等大量内置方法且可以扩展内置方法
Query查询
List<User> list = userDao.createQuery().andEq("name","hi").orderBy("create_date").select();
如果是Java8,且引入了对jaque库依赖,则可以
List<User> list1 = userDao.createQuery().lamdba().andEq(User::getName, "hi").orderBy(User::getCreateDate).select();
管理SQL
@SqlResource("console.user")
public interface UserConsoleDao extends BaseMapper<SysUser> {
void batchDelUserByIds(List<Long> ids);
void batchUpdateUserState( List<Long> ids, GeneralStateEnum stateEnum);
@Sql("update sys_user set password=? where id=?")
int changePassword(String newPassword,long id);
}
对应的sql文件是console/user.md,内容如下
batchDelUserByIds === update SYS_USER u set u.del_flag = 1 where u.id in( #join(ids)#) batchUpdateUserState === update SYS_USER u set u.state = #state# where u.id in( #join(ids)#)
关系映射
selectUserAndDepartment
===
select * from user where user_id=#userId#
@ orm.single({"departmentId":"id"},"Department");
@ orm.many({"id":"userId"},"user.selectRole","Role");
user.selectRole
===
select r.* from user_role ur left join role r on ur.role_id=r.id
where ur.user_id=#userId#
也支持注解说明映射关系
与hiberante,myabtis比较
Inside Larry's and Sergey's Brain
Richard Brandt / Portfolio / 17 Sep 2009 / USD 24.95
You’ve used their products. You’ve heard about their skyrocketing wealth and “don’t be evil” business motto. But how much do you really know about Google’s founders, Larry Page and Sergey Brin? Inside......一起来看看 《Inside Larry's and Sergey's Brain》 这本书的介绍吧!
