- Query功能支持Optional参数,如果为空,则andEq不生效
lambdaQuery.andEq(User::getName, Optional.ofNullable(name)).count();
- 允许Mapper方法在JDK 代理基础上,再次被代理。
public static interface UserMapper<User>{
@Sql("select * from sys_user where id=? ")
@Datasource("crm1")
User selectById(Integer id);
@Sql("select * from sys_user where id=? ")
@Log()
User selectById2(Integer id);
}
这里,Datasource注解和Log注解均为自定义注解,以Log注解实现为例子,使用@MapperProxy申明实现类
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})
@MapperProxy(LogExecutor.class)
public @interface Log {
String value() default "";
}
public static class LogExecutor implements MapperProxyExecutor {
@Override
public Object after(ProxyContext context,Object ret) {
System.out.println("log "+ret);
return ret;
}
}
Maven
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetlsql</artifactId>
<version>3.4.2-RELEASE</version>
</dependency>
BeetlSQL 研发自2015年,目标是提供开发高效,维护高效,运行高效的数据库访问框架,它适用范围广,定制性强,写起数据库访问代码特别顺滑,不亚于MyBatis.目前支持的数据库如下
- 传统数据库:MySQL,MariaDB,Oralce,Postgres,DB2,SQL Server,H2,SQLite,Derby,神通,达梦,华为高斯,人大金仓,PolarDB 等
- 大数据:HBase,ClickHouse,Cassandar,Hive
- 物联网时序数据库:Machbase,TD-Engine,IotDB
- SQL查询引擎:Drill,Presto,Druid
- 内存数据库:ignite,CouchBase
阅读文档 源码和例子 在线体验
BeetlSQL也支持IDEA插件,提供向导和自动提示
![]()