package org.codiki.core.entities.persistence;

import org.hibernate.annotations.Proxy;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="comment_history")
@Proxy(lazy = false)
public class CommentHistory implements Serializable {
	private static final long serialVersionUID = 1L;

	/* ******************* */
	/* Attributes */
	/* ******************* */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	private String text;

	/* ******************* */
	/* Relations */
	/* ******************* */
	@Column(name = "update_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date updateDate;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "comment_id")
	private Comment comment;

	/* ******************* */
	/* Getters & Setters */
	/* ******************* */
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		if(this.id != null) {
			throw new IllegalAccessError("It's not allowed to rewrite the id entity.");
		}
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Comment getComment() {
		return comment;
	}

	public void setComment(Comment comment) {
		this.comment = comment;
	}
	
}
