package com.peetz.comics.entity;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@NamedQueries({
	@NamedQuery(name="StoryArc.findAll", query="SELECT a from StoryArcEntity as a"),
	@NamedQuery(name="StoryArc.findByArtist", query="SELECT a from StoryArcEntity as a WHERE a.title = :title")
})

@Entity
@Table(name="STORYARC")
public class StoryArcEntity {

    private Long id;

    private String title;

    private Collection<IssueEntity> issues = new ArrayList<IssueEntity>();

    private ComicEntity comic;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public Long getId() { return id; }
	
    @SuppressWarnings("unused")
    private void setId(Long id) { this.id = id; }

    @Column
    public String getTitle() { return title; }

    public void setTitle(String title) { this.title = title; }

    public void setIssues(Collection<IssueEntity> issues) { this.issues = issues; }

    @OneToMany(mappedBy="storyArc", cascade=CascadeType.REMOVE)
    public Collection<IssueEntity> getIssues() { return issues; }

    public void setComic(ComicEntity comic) { this.comic = comic; }

    @ManyToOne
    public ComicEntity getComic() { return comic; }
}
