⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commentdao.java

📁 不说了
💻 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 + -