package com.hyzl.model; import com.hyzl.model.BaseObject; import org.hibernate.annotations.GenericGenerator; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Indexed; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OrderBy; import javax.persistence.Table; import javax.persistence.GeneratedValue; import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; /** * 实体:KNOWLEDGE_THEME * 作者:AppFuse * 公司:红有智联信息技术有限公司 * 时间:2014-9-9 10:15:18 */ @Entity @Table(name="KNOWLEDGE_THEME",schema="KBMS") @Indexed @XmlRootElement public class KnowledgeTheme extends BaseObject implements Serializable { private static final long serialVersionUID = 1L; /* * 标识 */ private String id; /*
* 父主题 */ private KnowledgeTheme parent; private Set knowledgeArticles = new HashSet(0); private Set children = new HashSet(0); @Id @GeneratedValue(generator="generator") @GenericGenerator(name="generator", strategy="uuid.hex") @DocumentId public String getId() { return this.id; } public void setId(String id) { this.id = id; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="PARENT_ID") public KnowledgeTheme getParent() { return this.parent; } public void setParent(KnowledgeTheme parent) { this.parent = parent; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="knowledgeTheme") public Set getKnowledgeArticles() { return this.knowledgeArticles; } public void setKnowledgeArticles(Set knowledgeArticles) { this.knowledgeArticles = knowledgeArticles; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="parent") @OrderBy(value = "themeName ASC") public Set getChildren() { return this.children; } public void setChildren(Set children) { this.children = children; } }