MiniDao 是一款轻量JAVA持久层架构,根据 SpringJdbc Freemarker 完成,具有Mybatis一样的SQL分离出来和逻辑性标识工作能力。Minidao造成的初心是为了更好地处理Hibernate新项目,在繁杂SQL具有Mybatis一样的灵便工作能力,另外适用事务管理同歩。
当今版本号:v1.7.1 | 2021-03-29
- An powerful enhanced toolkit of SpringJdbc for simplify development
具备下列特点:
- @MiniDao
- public interface EmployeeDao {
- @Arguments({ "employee"})
- @Sql("select * from employee")
- List<Map<String,Object>> getAll(Employee employee);
- @Sql("select * from employee where id = :id")
- Employee get(@Param("id") String id);
- @Sql("select * from employee where empno = :empno and name = :name")
- Map getMap(@Param("empno")String empno,@Param("name")String name);
- @Sql("SELECT count(*) FROM employee")
- Integer getCount();
- int update(@Param("employee") Employee employee);
- void insert(@Param("employee") Employee employee);
- @ResultType(Employee.class)
- public MiniDaoPage<Employee> getAll(@Param("employee") Employee employee,@Param("page") int page,@Param("rows") int rows);
[EmployeeDao_getAllEmployees.sql]
- SELECT * FROM employee where 1=1
- <#if employee.age ?exists>
- and age = :employee.age
- </#if>
- <#if employee.name ?exists>
- and name = :employee.name
- </#if>
- <#if employee.empno ?exists>
- and empno = :employee.empno
- </#if>
- public class Client {
- public static void main(String args[]) {
- BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
- EmployeeDao employeeDao = (EmployeeDao) factory.getBean("employeeDao");
- Employee employee = new Employee();
- String id = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
- employee.setId(id);
- employee.setEmpno("A001");
- employee.setSalary(new BigDecimal(5000));
- employee.setBirthday(new Date());
- employee.setName("scott");
- employee.setAge(25);
- //启用minidao方式插进
- employeeDao.insert(employee);
- }
- }