当前位置: 软件>java软件
轻量级 ORM 框架 Generic DAO
Generic DAO 是一个 Java 的轻量级 ORM 框架,允许开发者为持久化对象编写 DAO 类。
示例代码:
public class BlogLogicImpl implements BlogLogic {
private BlogWowDaoImpl dao;
public void setDao(BlogWowDaoImpl dao) {
this.dao = dao;
}
public BlogWowBlog getBlogByLocationAndUser(String locationId, String userId) {
List l = dao.findBySearch(BlogWowBlog.class, new Search("location", locationId) );
if (l.size() = 1) {
// found existing blog
return (BlogWowBlog) l.get(0);
}
}
...
}