Sqlbean 1.5.8 发布,SQL 语句交给编码生成
Sqlbean是一款使用Java面向对象思想来编写并生成Sql语句的工具,在此基础上对Mybatis和Spring Jdbc实现了类似于JPA的轻量级插件支持。其中内置大量常用SQL执行的方法,可以非常方便的达到你想要的目的,相对复杂的SQL语句也得以支持,在常规的项目开发几乎做到不写DAO层,可以有效的提高项目开发的效率,让开发者更专注于业务代码的编写。
🚀特点: 零入侵, 多数据源, 动态Schema, 读写分离, 自动建表, 连表查询, 乐观锁, 分页, 支持Mybatis和Spring Jdbc
💻环境: JDK8+, Mybatis3.2.4+, (Spring MVC 4.1.2+, Spring Boot 1.x, Spring Boot 2.x)
💿数据库: Mysql, MariaDB, Oracle, Sqlserver2008+, PostgreSQL, DB2, Derby, Sqlite, HSQL, H2
Sqlbean For Android请移步这里👉 gitee, github
简单上手
1.引入Maven依赖
<dependency> <groupId>cn.vonce</groupId> <artifactId>vonce-sqlbean-spring</artifactId> <version>1.5.8</version> </dependency>
2.标注实体类
@SqlTable("d_essay") public class Essay { @SqlId(type = IdType.SNOWFLAKE_ID_16) private Long id; private String userId; private String content; private Date creationTime; private Date updateTime; /**省略get set方法*/ }
3.无需Dao层,Service层接口只需继承SqlBeanService<实体类, id类型>
public interface EssayService extends SqlBeanService<Essay, Long> { //已内置大量常用查询、更新、删除、插入方法,这里可以写自己封装的方法 }
4.Service实现类只需继承MybatisSqlBeanServiceImpl<实体类, id类型>和实现你的Service接口
//使用Spring Jdbc的话将继承的父类改成SpringJdbcSqlBeanServiceImpl即可 @Service public class EssayServiceImpl extends MybatisSqlBeanServiceImpl<Essay, Long> implements EssayService { }
5.Controller层
@RequestMapping("essay") @RestController public class EssayController { @Autowired private EssayService essayService; //查询 @GetMapping("select") public RS select() { //查询列表 List<Essay> list = essayService.selectAll(); list = essayService.selectByCondition(Wrapper.where(gt(Essay$.id, 10)).and(lt(Essay$.id, 20))); //查询一条 Essay essay = essayService.selectById(1L); essay = essayService.selectOneByCondition(Wrapper.where(eq(Essay$.id, 333))); //复杂查询 Select select = new Select(); select.column(Essay$.id).column(Essay$.content); select.where().gt(Essay$.id, 1).and().eq(Essay$.content, "222"); select.orderByDesc(Essay$.creation_time); list = essayService.select(select); //用于查询Map Map<String, Object> map = essayService.selectMap(select); List<Map<String, Object>> mapList = essayService.selectMapList(select); return super.successHint("获取成功", list); } //分页 @GetMapping("getList") public Map getList(HttpServletRequest request) { // 查询对象 Select select = new Select(); ReqPageHelper<Essay> pageHelper = new ReqPageHelper<>(request); pageHelper.paging(select, essayService); return pageHelper.toResult("获取列表成功"); } //更新 @PostMapping("update") public RS update(Essay essay) { //根据bean内部id更新 long i = essayService.updateByBeanId(essay); //根据条件更新 //i = essayService.updateByCondition(Wrapper.where(gt(Essay$.id, 1)).and(eq(Essay$.content, "222"))); if (i > 0) { return super.successHint("更新成功"); } return super.othersHint("更新失败"); } //删除 @PostMapping("deleteById") public RS deleteById(Integer[] id) { //根据id删除 long i = essayService.deleteById(id); //根据条件删除 //i = essayService.deleteByCondition(Wrapper.where(gt(Essay$.id, 1)).and(eq(Essay$.content, "222"))); if (i > 0) { return super.successHint("删除成功"); } return super.othersHint("删除失败"); } //插入 @PostMapping("add") public RS add() { List<Essay> essayList = new ArrayList<>(); for (int i = 0; i < 100; i++) { Essay essay = new Essay(i, "name" + i); essayList.add(essay); } essayService.insert(essayList); return successHint("成功"); } }
本次更新内容:
1:修复@SqlJoin连表查询指定查询字段失效问题;
2:修改获取全部字段的顺序,父类字段显示在前面;
3:修复只有一个小写字母时驼峰转下划线失效问题;
4:修复连表查询VO类没有标识注解或继承类时导致的问题;
5:修复如果有连表查询时自动生成的where条件没有生成全名导致异常的问题;
6:修复其他内容;
关注公众号
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
mica-auto 2.3.0 发布,支持 SpringBoot 2.7.0 新特性
更新记录 ✨ 支持 Spring boot 2.7.0 新特性 @AutoConfiguration。 ⬆️ 升级 Spring boot 到 2.7.0 注意:mica-auto 并不强制依赖 Spring boot,仅仅是组合了 spring-boot-configuration-processor依赖,方便使用。mica-auto 2.3.0 理论上支持 Spring boot 所有版本。 关于 Spring boot 2.7.0 @AutoConfiguration 1 @AutoConfiguration 注解 Spring boot 2.7.0 新增 @AutoConfiguration 注解,它用来替换 @Configuration 注解, 我们可以看到它组合了 @Configuration(默认 proxyBeanMethods = false 配置类不进行代理,可节省资源另外对 GraalVM 更加友好)、@AutoConfigureAfter 和 @AutoConfigureBefore 方便使用。 另外 Spring boot 2.7.0 开始推荐使用 META-...
-
下一篇
酷瓜云课堂(腾讯云)企业版 v1.0.4 发布
更新内容 增加移动端图形验证码 增加移动端海报 增加移动端秒杀 增加移动端团购 增加移动端积分商城 增加移动端分销市场 增加移动端优惠券 增加移动账户安全 增加移动端收货地址 增加游客下载课件限制 增加授权到期提醒 修复首页简洁模式下样式问题 修复删除群组前台依旧显示问题 修复兑换课程用户课程数未增加问题 调整分享链接服务目录结构 若干查询完善 deleted=0,published=1 条件 增加 meta renderer 标识方便 360 识别 webkit 模式 vidtor 本地话,弃用 cdn.jsdelivr.net 优化会员套餐价格排序 系统介绍 酷瓜云课堂,依托腾讯云基础服务架构,采用 C 扩展框架 Phalcon 开发,致力在线教育系统。 系统功能 实现了点播、直播、专栏、面授、问答、会员、群组、微聊、积分、秒杀、拼团、分销等。 友情提示 请使用干净的系统执行安装,如有安装过 nginx,apache 之类的占用 80 和 443 端口的 web 服务会造成端口冲突 配置要求 操作系统:Ubuntu | Debain | Centos 系统内存:2G+ 申请试用授权...
相关文章
文章评论
共有0条评论来说两句吧...

微信收款码
支付宝收款码