📄 commentservice.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 + -