package models;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.Constraint;

import play.db.ebean.Model;

@Entity  
@Table(name="keyword")
public class Keyword extends Model{

	/**
	 * 
	 */
	private static final long serialVersionUID = 9177310329978137971L;
	
	@Id
	@GeneratedValue
	public Long id;
	
	@Column(name="key")
	public String key;
	
	@ManyToMany(mappedBy="keywords")
	@JoinTable(name="article_keyword")
	public List<Article> articles;
	
	public Keyword(){
		
	}
	
	public Keyword(String key){
		this.key = key;
	}
	
	public void addArticle(Article a){
		this.articles.add(a);
		this.update();
	}
	
	public void removeArticle(Article a){
		this.articles.remove(a);
		this.update();
	}
	
	public List<Article> getArticles(){
		return this.articles;
	}
	
	public void setArticles(List<Article> articles){
    	this.articles = articles;
    }

}

@@ -1,8 +1,37 @@
+/**%0A * @author Hao ZHANG%0A */%0A
 package 
@@ -67,46 +67,8 @@
 t;%0A%0A
-import javax.persistence.CascadeType;%0A
 impo
@@ -308,45 +308,8 @@
 le;%0A
-import javax.validation.Constraint;%0A%0A
 impo

add keyword