内容简介:本次更新建议升级 更新Beetl到最新的2.7.27,Beetl的上一个版本对注释处理有错误 <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetlsql</artifactId> <version>2.10.1...
本次更新建议升级
更新Beetl到最新的2.7.27,Beetl的上一个版本对注释处理有错误
<dependency> <groupId>com.ibeetl</groupId> <artifactId>beetlsql</artifactId> <version>2.10.13</version> </dependency>
BeetlSQL是以 SQL 为中心的Dao工具,具备如下功能
内置增删改查
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();如果是 Java 8,且引入了对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 比较
【声明】文章转载自:开源中国社区 [http://www.oschina.net]
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Think Python
Allen B. Downey / O'Reilly Media / 2012-8-23 / GBP 29.99
Think Python is an introduction to Python programming for students with no programming experience. It starts with the most basic concepts of programming, and is carefully designed to define all terms ......一起来看看 《Think Python》 这本书的介绍吧!