[构建自己的持久层]六、开始开发DAO之一
2010-08-27 13:59
351 查看
DAO的接口,我们暂时留了这些接口
package com.cat.xtools;
import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import com.cat.xtools.conn.Result;
import com.cat.xtools.exception.DAOException;
/**
* DAO<br>
* <p>
* 修改日期:2006-1-25
* <p>
* 修改说明:
* <p>
* 版权所有:Copyright 2006 软件有限公司, Inc. All rights reserved.
*
* @version 1.0
* @author 侯正刚
* @since 1.0
*/
public interface DAO {
/**
* 开始事务处理
* @throws DAOException
*/
public void begintransaction()throws DAOException;
public boolean getIscommit();
/**
* 事务回滚
*
*/
public void rollback();
/**
* 提交事务
*
*/
public void commit();
/**
* 查询
* @param sql
* @param parameters
* @param start -1
* @param end -1
* @return
*/
public Result query(String sql,Object[] parameters,int start,int end)throws DAOException;
/**
* 查询
* @param sql
* @param parameters
* @return
*/
public Result query(String sql,Object[] parameters)throws DAOException;
/**
* 查询
* @param sql
* @return
*/
public Result query(String sql)throws DAOException;
/**
* 执行
* @param sql
* @param parameters
* @return
*/
public boolean execute(String sql,Object[] parameters)throws DAOException;
/**
* 执行
* @param sql
* @return
*/
public boolean execute(String sql)throws DAOException;
/**
* 保存实体
* @param pojo
* @param id
* @return
* @throws DAOException
*/
public Serializable save(PojoRoot pojo,Serializable id) throws DAOException;
/**
* 保存实体
* @param pojo
* @return
* @throws DAOException
*/
public Serializable save(PojoRoot pojo) throws DAOException;
/**
* 修改实体
* @param pojo
* @throws DAOException
*/
public void update(PojoRoot pojo) throws DAOException;
/**
* 保存或修改
* @param pojo
* @return
* @throws DAOException
*/
public Serializable saveOrupdate(PojoRoot pojo)throws DAOException;
/**
* 通过ID实例化一个POJO
* @param cls
* @param id
* @return
* @throws DAOException
*/
public PojoRoot load(Class cls,Serializable id)throws DAOException;
/**
* 通过ID实例化一个POJO
* @param entity 构件
* @param id
* @return
* @throws DAOException
*/
public PojoRoot load(Entity entity,Serializable id)throws DAOException;
/**
* 从数据库中永久删除一个POJO
* @param pojo
* @throws DAOException
*/
public void delete(PojoRoot pojo) throws DAOException;
/**
* 分页查询
* @param sql
* @param sqlcount
* @param parameter
* @param pageSize
* @param request
* @return
* @throws DAOException
*/
public Result queryByPage(String sql,String sqlcount,Object[] parameter,int pageSize,HttpServletRequest request)throws DAOException;
}
分页查询暂时可以先不用实现,只实现
/**
* 查询
* @param sql
* @param parameters
* @param start
* @param end
* @return
*/
public Result query(String sql,Object[] parameters,int start,int end)throws DAOException;
即可
这里的意思就是取第start包括start,到end包括end的记录
Result 为离线结果集。
package com.cat.xtools;
import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import com.cat.xtools.conn.Result;
import com.cat.xtools.exception.DAOException;
/**
* DAO<br>
* <p>
* 修改日期:2006-1-25
* <p>
* 修改说明:
* <p>
* 版权所有:Copyright 2006 软件有限公司, Inc. All rights reserved.
*
* @version 1.0
* @author 侯正刚
* @since 1.0
*/
public interface DAO {
/**
* 开始事务处理
* @throws DAOException
*/
public void begintransaction()throws DAOException;
public boolean getIscommit();
/**
* 事务回滚
*
*/
public void rollback();
/**
* 提交事务
*
*/
public void commit();
/**
* 查询
* @param sql
* @param parameters
* @param start -1
* @param end -1
* @return
*/
public Result query(String sql,Object[] parameters,int start,int end)throws DAOException;
/**
* 查询
* @param sql
* @param parameters
* @return
*/
public Result query(String sql,Object[] parameters)throws DAOException;
/**
* 查询
* @param sql
* @return
*/
public Result query(String sql)throws DAOException;
/**
* 执行
* @param sql
* @param parameters
* @return
*/
public boolean execute(String sql,Object[] parameters)throws DAOException;
/**
* 执行
* @param sql
* @return
*/
public boolean execute(String sql)throws DAOException;
/**
* 保存实体
* @param pojo
* @param id
* @return
* @throws DAOException
*/
public Serializable save(PojoRoot pojo,Serializable id) throws DAOException;
/**
* 保存实体
* @param pojo
* @return
* @throws DAOException
*/
public Serializable save(PojoRoot pojo) throws DAOException;
/**
* 修改实体
* @param pojo
* @throws DAOException
*/
public void update(PojoRoot pojo) throws DAOException;
/**
* 保存或修改
* @param pojo
* @return
* @throws DAOException
*/
public Serializable saveOrupdate(PojoRoot pojo)throws DAOException;
/**
* 通过ID实例化一个POJO
* @param cls
* @param id
* @return
* @throws DAOException
*/
public PojoRoot load(Class cls,Serializable id)throws DAOException;
/**
* 通过ID实例化一个POJO
* @param entity 构件
* @param id
* @return
* @throws DAOException
*/
public PojoRoot load(Entity entity,Serializable id)throws DAOException;
/**
* 从数据库中永久删除一个POJO
* @param pojo
* @throws DAOException
*/
public void delete(PojoRoot pojo) throws DAOException;
/**
* 分页查询
* @param sql
* @param sqlcount
* @param parameter
* @param pageSize
* @param request
* @return
* @throws DAOException
*/
public Result queryByPage(String sql,String sqlcount,Object[] parameter,int pageSize,HttpServletRequest request)throws DAOException;
}
分页查询暂时可以先不用实现,只实现
/**
* 查询
* @param sql
* @param parameters
* @param start
* @param end
* @return
*/
public Result query(String sql,Object[] parameters,int start,int end)throws DAOException;
即可
这里的意思就是取第start包括start,到end包括end的记录
Result 为离线结果集。
相关文章推荐
- [构建自己的持久层]七、开始开发DAO之二
- 构建自己的C/C++插件开发框架(三)——总体结构
- 毫无废话: 从0开始一点一滴用java开发自己的B/S--3.2
- 毫无废话: 从0开始一点一滴用java开发自己的B/S模式程序---5.2
- 构建自己的C/C++插件开发框架(三)——总体结构
- VSX开发之语言服务系列(4)——从空Package开始构建语言服务框架
- 构建自己的C/C++插件开发框架
- [构建自己的持久层]五、Entity对象描述
- 构建自己的.NET Framework3.0开发环境
- 毫无废话: 从0开始一点一滴用java开发自己的B/S---5.1
- 毫无废话: 从0开始一点一滴用java开发自己的B/S模式程序-5.3
- [翻译]如何开始开发自己的操作系统
- 构建自己的C/C++插件开发框架(二)——总体功能
- 从今天开始学习iOS开发(iOS 7版)--构建一款App之设计用户界面
- 构建自己的插件开发框架(c++)
- 构建自己的C/C++插件开发框架(一)——初步设想
- dao-service-servlet-jsp构建简易web通讯录(三层开发)bug1
- ubuntu 下使用 Python 和 SL4A 的 Android 应用程序构建您自己的android开发环境
- 毫无废话: 从0开始一点一滴用java开发自己的B/S--4.2
- 构建自己的C/C++插件开发框架(一)——初步设想