Minidao 1.6.2 version released, ultra-lightweight Java persistence framework (Hibernate perfect assistant)

The original intention of Minidao?

     J2EE projects that use Hibernate have a painful problem. For complex business SQL, hibernate has insufficient capabilities, and SQL is not well optimized and cannot be separated. At this time, everyone thought of integrating mybatis, but a project using both hibernate and mybatis seems to be very transactional and difficult to control. The common practice is to use springjdbc to write native SQL, but there are also problems. SQL cannot be separated and has no logical labeling capability.

   So in order to solve this pain, Jeecg has encapsulated springjdbc+freemarker, and created such a lightweight persistence layer, which allows Hiberate to have the same SQL flexibility as mybatis, while supporting transaction unification and SQL labeling capabilities.

upgrade log

  • Support auto-increment primary key strategy mode

  • Support custom extended primary key strategy

  • New example: auto-incrementing primary key strategy mode

  • New Example: Stored Procedure Call

  • New Example: Custom Pagination

Introduction to MiniDao

     MiniDao is a lightweight JAVA persistence layer framework, based on SpringJdbc + freemarker implementation, with the same SQL separation flexibility and logical tags as Mybatis. The biggest advantage: It can seamlessly integrate Hibernate projects, support unified transaction management, effectively solve Hibernate projects, and realize flexible SQL separation problems.

Features of MiniDao

  • O/R mapping does not need to set xml, zero configuration is easy to maintain

  • No knowledge of JDBC is required

  •  Separation of SQL statements and java code

  •  SQL supports scripting language

  • Supports automatic transaction processing and manual transaction processing

  • Supports lightweight and seamless integration with hibernate

  • Only interface definition is required, no interface implementation is required

Source code download

Source code interpretation

    Interface definition:

@MiniDao  
public interface EmployeeDao {  
  
 public List<Map> getAllEmployees(@Param("employee") Employee employee);  
  
 Employee getEmployee(@Param("empno") String empno);  
  
 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);  
}

    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>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326284047&siteId=291194637