commentservice.java
来自「在线信息发布系统。在Eclipse下进行开发结合了struts等主流技术」· Java 代码 · 共 65 行
JAVA
65 行
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 + =
减小字号Ctrl + -
显示快捷键?