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

📄 paper.java

📁 Hibernate基础教程一书源码.Hibernate是一个持久层开源框架
💻 JAVA
字号:
package com.hibernatebook.spring;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Paper {
	private Integer id = null;
	private String title = null;
	private Set<Article> articles = null;
	
	public Paper(String title) {
		this.title = title;
		this.articles = new HashSet<Article>();
	}
	
	protected Paper() {
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return this.id;
	}
	
	public String getTitle() {
		return title;
	}

	@OneToMany(cascade=ALL,fetch=LAZY)
	public Set<Article> getArticles() {
		return articles;
	}

	protected void setId(Integer id) {
		this.id = id;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	protected void setArticles(Set<Article> articles) {
		this.articles = articles;
	}
	
	public void addArticle(Article article) {
		this.getArticles().add(article);
	}
}

⌨️ 快捷键说明

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