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

📄 commentservice.java

📁 在线信息发布系统。在Eclipse下进行开发结合了struts等主流技术
💻 JAVA
字号:
package service;

import java.util.*;

import po.comment.*;
import po.news.Newst;
import po.news.NewstDAO;
import hibernate.*;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class CommentService {
	
	/*
	 * 新闻评论列表显示
	 */
	public static List commentList(Commentt comment)
	{		
		CommenttDAO dao = new CommenttDAO();
		
		try{
			List list=dao.findByExample(comment);
			
			return list;
			
		}catch(HibernateException e){
			return null;
		}finally{
			try  { 
		        dao.getSession().close();
		      } catch  (Exception e) { 
		      }
		}
	}
	
	/*
	 * 新闻评论发布:添加一条新闻评论
	 */
	public static boolean addComment(Commentt comment)
	{
		CommenttDAO dao = new CommenttDAO();
		
		try{
			Session session=dao.getSession();
			Transaction tx=session.beginTransaction();

			dao.save(comment);
			session.flush();
			
			tx.commit();
			
			return true;
			
		}catch(HibernateException e){
			return false;
		}finally{
			try  { 
		        dao.getSession().close();
		      } catch  (Exception e) { 
		      }
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -