`
jinxhj2003
  • 浏览: 145256 次
  • 性别: Icon_minigender_1
  • 来自: 南昌
社区版块
存档分类
最新评论

一个hibernate Dao

阅读更多
package com.lcsssh.dao.base;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.lcsssh.bo.PageInfo;


/**
* com.iss.crm.hibernate.base.HibernateBaseDAO
* @author Administrator
*
*/
public interface BaseDao {

/**
* 根据主键ID查询对象
* @param c
* @param id
* @return Object
*/
Object getById(Class c, Serializable id);

/**
* 查询一个类的所有对象
* @param c
* @return List
*/
List getAll(Class c);
/**
* 查询一个类的所有对象2
* @param c
* @return List
*/
List getAll(String strHQL);

/**
* 保存或者更新一个对象
* 当对象为临时状态时就保存对象
* 当对象为持久化或者游离状态时就更新对象
* @param o
*/
void saveOrUpdate(Object o);

/**
* 移除一个对象
* @param o
*/
void delete(Object o);

/**
* 使用给定的HQL字符串查询
* @param strHQL
* @return List
*/
List findByHQL(final String strHQL);

/**
* 根据给定的HQL语句与映射条件查询
* 用于复杂的查询语句 我们在代入查询参数的时候,
* 建议使用 name里面放的是HQL语句
* eg: "from Courses where name = :name"
* map里面放的是你想绑定的参数实现集
* eg: Map map = new HashMap();
* map.put("name", "Tom");
* 最后得到的结果就是 from Courses where name = Tom
* @param strHQL
* @param mapping
* @return List
*/
List findByHQL(final String strHQL, final Map mappings);

/**
* 得到分页查询的记录
* @param StrHQL
* @param mappings
* @param pageInfo
* @return List
* @throws DataAccessException
*/
List getQueryResult(final String strHQL, final Map mappings,
final PageInfo pageInfo) throws DataAccessException;

/**
* 根据传入的查询语句的到记录的条数
* @param StrHQL
* @param mappings
* @return int
* @throws DataAccessException
*/
int getQueryCount(final String strHQL, final Map mappings)
throws DataAccessException;

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics