BeetlSQL 2.10.19 发布了,本次发布改善了多个功能
新增join函数支持属性
#IIF90 支持 逻辑删除 ,使用@LogicDelete注解
#II5M4 Lambda 支持改用jdb8内置的方式,不需额外的jar
#IIUQHQuery 查询允许复用
修复
#IIOJK关于Query对象检查sql语法的bug
Maven
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetlsql</artifactId>
<version>2.10.19</version>
</dependenc
Spring Boot
<dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl-framework-starter</artifactId> <version>1.1.45.RELEASE</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);
....等等大量内置方法且可以扩展内置方法
List<User> list = userDao.createQuery().andEq("name","hi").orderBy("create_date").select();
如果是Java8
List<User> list1 = userDao.createLamdba().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#