package com.beehive.db.entity.news;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.CollectionOfElements;
import com.beehive.db.entity.account.User;
@Entity
public class News {
private long id;
private String title;
private String source;
private String content;
private Channel channel;
private boolean visible;
private boolean top;
private boolean hot;
private List<String> keywords = new ArrayList<String>();
private List<User> authors = new ArrayList<User>();
private Date createDate;
private long readTimes;
private long commentTimes;
@Id
@GeneratedValue
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
@Lob
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@ManyToOne(cascade=CascadeType.ALL,targetEntity=Channel.class)
@JoinColumn(name="channel_id")
public Channel getChannel() {
return channel;
}
public void setChannel(Channel channel) {
this.channel = channel;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public boolean isTop() {
return top;
}
public void setTop(boolean top) {
this.top = top;
}
public boolean isHot() {
return hot;
}
public void setHot(boolean hot) {
this.hot = hot;
}
@CollectionOfElements(targetElement=String.class)
public List<String> getKeywords() {
return keywords;
}
public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}
@ManyToMany(targetEntity=User.class,cascade=CascadeType.ALL,fetch=FetchType.EAGER)
@JoinTable(joinColumns={@JoinColumn(name="news_id")}, inverseJoinColumns={@JoinColumn(name="author_id")})
public List<User> getAuthors() {
return authors;
}
public void setAuthors(List<User> authors) {
this.authors = authors;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public long getReadTimes() {
return readTimes;
}
public void setReadTimes(long readTimes) {
this.readTimes = readTimes;
}
public long getCommentTimes() {
return commentTimes;
}
public void setCommentTimes(long commentTimes) {
this.commentTimes = commentTimes;
}
}
|