更新内容
1、修复批量操作默认autoCommit默认为false导致分布式事务错误
范例地址:https://github.com/chenrenfei/sqltoy-showcase/tree/master/trunk/sqltoy-sharding
分库分表说明: https://chenrenfei.github.io/sqltoy/#/sqltoy/sharding
sqltoy特点说明:
- 支持mysql、postgresql、db2、oracle、sqlserver、sqlite、clickhouse、elasticsearch等
- 具有JPA模式的CRUD功能(即CRUD无需写sql),无需写Dao,sqltoy提供了SqlToyLazyDao,同时提供了quickvo从数据库生成POJO。
- 根本上杜绝了sql注入问题
- 最科学的sql编写方式
* sqltoy的sql编写(支持嵌套)
select *
from sqltoy_device_order_info t
where #[t.ORDER_ID=:orderId]
#[and t.ORGAN_ID in (:authedOrganIds)]
#[and t.STAFF_ID in (:staffIds)]
#[and t.TRANS_DATE>=:beginDate]
#[and t.TRANS_DATE<:endDate]
* mybatis同样功能实现
select *
from sqltoy_device_order_info t
<where>
<if test="orderId!=null">
and t.ORDER_ID=#{orderId}
</if>
<if test="authedOrganIds!=null">
and t.ORGAN_ID in
<foreach collection="authedOrganIds" item="order_id" separator="," open="(" close=")">
#{order_id}
</foreach>
</if>
<if test="staffIds!=null">
and t.STAFF_ID in
<foreach collection="staffIds" item="staff_id" separator="," open="(" close=")">
#{staff_id}
</foreach>
</if>
<if test="beginDate!=null">
and t.TRANS_DATE>=#{beginDate}
</if>
<if test="endDate!=null">
and t.TRANS_DATE<#{endDate}
</if>
</where>
- 缓存翻译大幅提升性能,减少多表关联,让sql直观可维护
- 最高等级的分页优化
- 支持用算法代替sql实现行列转换、同比环比、分组汇总等
- 支持分库分表
- sqltoy支持跨数据库函数自适应:一套sql可以自适应多种数据库
- 提供了5种默认的非数据库相关的主键策略
1、shortNanoTime 22位有序安全ID,格式: 13位当前毫秒+6位纳秒+3位主机ID
2、nanoTimeId 26位有序安全ID,格式:15位:yyMMddHHmmssSSS+6位纳秒+2位(线程Id+随机数)+3位主机ID
3、uuid:32 位uuid
4、SnowflakeId 雪花算法ID
5、redisId 基于redis 来产生规则的ID主键
- 提供了通用字段赋值处理
- 提供了树形表的统一处理机制
- sql文件更新自动重载,便于开发阶段无需重启应用
- 慢sql统计功能
开源地址: