标签:
https://github.com/zhangdaiscott/minidao-pe
MiniDao-PE 简介及特征
MiniDao-PE 是一种持久化解决方案,类似mybatis的持久层解决方案,可以轻松集成入Hibernate工程,事务统一管理,解决了Hibernate工程想支类mybaits的功能问题。 具有以下特征:
@MiniDao
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>
<!-- 注册MiniDao接口 -->
<bean class="org.jeecgframework.minidao.factory.MiniDaoBeanFactory">
<property name="packagesToScan">
<list>
<value>examples.dao.*</value>
</list>
</property>
</bean>
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"));
}
}
}
标签:
原文地址:http://www.cnblogs.com/meetrice/p/5267826.html