package com.ibtp.kontor.comics.entity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Created by thomas on 17.01.15.
 */
@NamedQueries({
        @NamedQuery(name="StoryArc.findAll", query="SELECT s from StoryArcEntity as s"),
        @NamedQuery(name="StoryArc.findByTitle", query="SELECT s from StoryArcEntity as s WHERE s.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; }
}
