?? commentdao.java
字號:
package com.david.dao;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.david.bo.Comment;
import com.david.bo.File;
import com.david.util.IPageBeanSH;
public class CommentDao extends HibernateDaoSupport implements ICommentDao {
private IPageBeanSH pageBeanSH;
public boolean addComment(Comment comment) {
// TODO Auto-generated method stub
try{
this.getHibernateTemplate().save(comment);
return true;
}catch(DataAccessException e){
e.printStackTrace();
return false;
}
}
public List<Comment> getCommentList(int start,File file) {
// TODO Auto-generated method stub
String hql="from Comment as comment where comment.file=? Order by comment.id desc";
File[] arrValues={file};
pageBeanSH.setHql(hql);
pageBeanSH.setStart(start);
pageBeanSH.setArrValues(arrValues);
List<Comment> list=null;
try {
list=(List<Comment>) pageBeanSH.doInHibernate(this.getSession());
} catch (DataAccessResourceFailureException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
public void setPageBeanSH(IPageBeanSH pageBeanSH) {
// TODO Auto-generated method stub
this.pageBeanSH=pageBeanSH;
}
public int getAllNum(File file) {
// TODO Auto-generated method stub
return this.getHibernateTemplate().find("from Comment as comment where comment.file=? Order by comment.id desc", file).size();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -