📄 commentbusiness.java
字号:
package com.stiven.business;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.stiven.hibernate.Blogentry;
import com.stiven.hibernate.BlogentryDAO;
import com.stiven.hibernate.Comments;
import com.stiven.hibernate.CommentsDAO;
public class CommentBusiness {
public boolean addComment(Comments comment){
BlogentryDAO dao=new BlogentryDAO();
Blogentry blogEntry=comment.getBlogentry();
Session session=dao.getSession();
try {
Transaction tran=session.beginTransaction();
blogEntry.getCommentses().add(comment);
session.save(blogEntry);
tran.commit();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public Set findCommentsByBlogEntry(Blogentry blog){
return blog.getCommentses();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -