1 Star 0 Fork 0

Jenkins / orange

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

概述

  • orange是一个动态sql引擎,类似mybatis的功能,解析带标签的动态sql,生成?占位符的sql和?对应的参数列表。
  • 借鉴了mybatis源码,相当于mybatis中的动态sql解析功能的抽取。
  • 支持 if foreach where set trim

使用教程

  • 先拉取源代码,安装到maven本地仓库:
mvn -DskipTests=true install
  • 安装到maven本地仓库后,就可以在自己的maven项目中使用orange了
#pom引入maven坐标
<dependency>
    <groupId>com.jq</groupId>
    <artifactId>orange</artifactId>
    <version>1.0</version>
</dependency>
#核心api
DynamicSqlEngine engine = new DynamicSqlEngine();
SqlMeta sqlMeta = engine.parse(sql, map);
#示例
@Test
public void testForeach() {
    DynamicSqlEngine engine = new DynamicSqlEngine();
    String sql = ("select * from user where name in <foreach collection='list' open='(' separator=',' close=')'>#{item.name}</foreach>");
    Map<String, Object> map = new HashMap<>();


    ArrayList<User> arrayList = new ArrayList<>();
    arrayList.add(new User(10, "tom"));
    arrayList.add(new User(11, "jerry"));
    map.put("list", arrayList);
  
    SqlMeta sqlMeta = engine.parse(sql, map);
    System.out.println(sqlMeta.getSql());
    sqlMeta.getJdbcParamValues().forEach(System.out::println);
}
#示例执行结果:
select * from user where name in  ( ? , ? ) 
tom
jerry

联系作者:

wechat:

捐赠:

如果您喜欢此项目,请给作者加鸡腿

Comments ( 0 )

Sign in for post a comment

About

No description spread retract
Java
GPL-2.0
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://gitee.com/shuitai/orange.git
git@gitee.com:shuitai/orange.git
shuitai
orange
orange
master

Search

102255 3a0e046c 1850385 102255 7aaa926c 1850385