?? cpdaohibernate.java
字號:
package com.longtime.wap.module.cost.dao.hibernate;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import com.longtime.wap.common.BaseDao;
import com.longtime.wap.model.Cp;
import com.longtime.wap.module.cost.dao.CpDao;
/**
* CpDao層實現代碼
*
* @author chenxq
* @date 2007-11-23
*/
public class CpDaoHibernate extends BaseDao implements CpDao {
/**
* 用來實現“獲取單位對象集合”的功能
*
* @return 單位對象集合
*/
public List retrieveCps() {
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
StringBuilder hql = new StringBuilder("from Cp");
Query query = session.createQuery(hql.toString());
return query.list();
}
});
}
/**
* 通過公司Id獲得公司對象
*
* @param cpId
* 公司Id
* @return 公司對象
*/
public Cp retrieveCpById(Long cpId) {
return (Cp) this.getHibernateTemplate().get(Cp.class, cpId);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -