package it.ramecera.screwdriver.waxds.copper;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/** The persistent class for the authors database table. */
@Entity
@Table(name = "authors", schema = "copper")
@NamedQuery(name = "Author.findAll", query = "SELECT a FROM Author a")
public class Author implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer star;

	private Timestamp creationdate;

	private String name;

	private String surname;

	private Timestamp updatedate;

	// bi-directional many-to-one association to Actor
	@ManyToOne
	@JoinColumn(name = "modifier")
	private Actor actor;

	// bi-directional many-to-one association to Novel
	@OneToMany(mappedBy = "authorBean")
	private List<Novel> novels;

	public Author() {
	}

	public Integer getStar() {
		return this.star;
	}

	public void setStar(Integer star) {
		this.star = star;
	}

	public Timestamp getCreationdate() {
		return this.creationdate;
	}

	public void setCreationdate(Timestamp creationdate) {
		this.creationdate = creationdate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return this.surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Timestamp getUpdatedate() {
		return this.updatedate;
	}

	public void setUpdatedate(Timestamp updatedate) {
		this.updatedate = updatedate;
	}

	public Actor getActor() {
		return this.actor;
	}

	public void setActor(Actor actor) {
		this.actor = actor;
	}

	public List<Novel> getNovels() {
		return this.novels;
	}

	public void setNovels(List<Novel> novels) {
		this.novels = novels;
	}

	public Novel addNovel(Novel novel) {
		getNovels().add(novel);
		novel.setAuthorBean(this);

		return novel;
	}

	public Novel removeNovel(Novel novel) {
		getNovels().remove(novel);
		novel.setAuthorBean(null);

		return novel;
	}

}