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

📄 commentbusiness.java

📁 开发工具为myeclipse,数据库为oracle
💻 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 + -