BeetlSQL 2.10.20 发布了,本次发布主要是同步更新了Beetl版本到2.8.0
#IIXR2 LambdaQuery asc desc方法的返回类型 问题修复
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetlsql</artifactId>
<version>2.10.20</version>
</dependency>
内置增删改查
- 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
List<User> list1 = userDao.createLambdaQuery().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#
转自 https://www.oschina.net/news/95439/beetlsql-2-10-20-released