日期:2014-05-18 浏览次数:20724 次
详细地址:http://zhangdaiscott.github.io/MiniDao/
源码下载地址:http://code.google.com/p/jeecg/downloads/list
MiniDao简介及特征
MiniDao是Jeecg自己的持久化解决方案,集成了Hibernate实体维护和Mybaits SQL分离的两大优势。 具有以下特征:
※向下兼容Hibernate实体维护方式,实体的增删改查SQL自动生成
public interface EmployeeDao {
@Arguments("employee")
public List<Map> getAllEmployees(Employee employee);
@Arguments("empno")
Employee getEmployee(String empno);
@Arguments({"empno","name"})
Map getMap(String empno,String name);
@Sql("SELECT count(*) FROM employee")
Integer getCount();
@Arguments("employee")
int update(Employee employee);
@Arguments("employee")
void insert(Employee employee);
}
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();
List<Map> list = employeeDao.getAllEmployees(employee);
for(Map mp:list){
System.out.println(mp.get("id"));
System.out.println(mp.get("name"));
System.out.println(mp.get("empno"));
System.out.println(mp.get("age"));
System.out.println(mp.get("birthday"));
System.out.println(mp.get("salary"));
}
}
}