MiniDao1.7.1 版本发布,轻量级Java持久化框架

MiniDao1.7.1 版本发布,轻量级Java持久化框架

首页游戏大全迷你世界1.10.1更新时间:2024-06-12
项目介绍

MiniDao 是一款轻量级JAVA持久层框架,基于 SpringJdbc freemarker 实现,具备Mybatis一样的Sql分离和逻辑标签能力。Minidao产生的初衷是为了解决Hibernate项目,在复杂SQL具备Mybatis一样的灵活能力,同时支持事务同步。

当前版本:v1.7.1 | 2021-03-29

源码下载升级日志技术文档MiniDao特征

An powerful enhanced toolkit of SpringJdbc for simplify development

具有以下特征:

代码体验1. 接口定义[EmployeeDao.java]

@MiniDao publicinterfaceEmployeeDao{ @Arguments({"employee"}) @Sql("select*fromemployee") List<Map<String,Object>>getAll(Employeeemployee); @Sql("select*fromemployeewhereid=:id") Employeeget(@Param("id")Stringid); @Sql("select*fromemployeewhereempno=:empnoandname=:name") MapgetMap(@Param("empno")Stringempno,@Param("name")Stringname); @Sql("SELECTcount(*)FROMemployee") IntegergetCount(); intupdate(@Param("employee")Employeeemployee); voidinsert(@Param("employee")Employeeemployee); @ResultType(Employee.class) publicMiniDaoPage<Employee>getAll(@Param("employee")Employeeemployee,@Param("page")intpage,@Param("rows")introws);

}

2. SQL文件

[EmployeeDao_getAllEmployees.sql]

SELECT*FROMemployeewhere1=1 <#ifemployee.age?exists> andage=:employee.age </#if> <#ifemployee.name?exists> andname=:employee.name </#if> <#ifemployee.empno?exists> andempno=:employee.empno </#if> 3. 接口和SQL文件对应目录

4. 测试代码

publicclassClient{ publicstaticvoidmain(Stringargs[]){ Beanfactoryfactory=newClassPathXmlApplicationContext("applicationContext.xml"); EmployeeDaoemployeeDao=(EmployeeDao)factory.getBean("employeeDao"); Employeeemployee=newEmployee(); Stringid=UUID.randomUUID().toString().replaceAll("-","").toUpperCase(); employee.setId(id); employee.setEmpno("A001"); employee.setSalary(newBigDecimal(5000)); employee.setBirthday(newDate()); employee.setName("scott"); employee.setAge(25); //调用minidao方法插入 employeeDao.insert(employee); } }

查看全文
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved