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.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@NamedQueries({
	@NamedQuery(name="Artist.findAll", query="SELECT a from ArtistEntity as a"),
	@NamedQuery(name="Artist.findByName", query="SELECT a from ArtistEntity as a WHERE a.name = :name")
})

@Entity
@Table(name="ARTIST")
public class ArtistEntity {
    
    private Long id;
	
    private String name;
	
    private Collection<IssueEntity> writtenIssues = new ArrayList<IssueEntity>();

	
    private Collection<IssueEntity> inkedIssues = new ArrayList<IssueEntity>();
	
    private Collection<IssueEntity> penciledIssues = new ArrayList<IssueEntity>();

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

    @Column
    public String getName() { return name; }

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

    public void setWrittenIssues(Collection<IssueEntity> writtenIssues) { this.writtenIssues = writtenIssues; }
	
    @OneToMany(mappedBy="writer", cascade=CascadeType.REMOVE)
    public Collection<IssueEntity> getWrittenIssues() {
        return writtenIssues;
    }

    public void setInkedIssues(Collection<IssueEntity> inkedIssues) { this.inkedIssues = inkedIssues; }

    @OneToMany(mappedBy="inker", cascade=CascadeType.REMOVE)
    public Collection<IssueEntity> getInkedIssues() {
        return inkedIssues;
    }

    public void setPenciledIssues(Collection<IssueEntity> penciledIssues) { this.penciledIssues = penciledIssues; }

    @OneToMany(mappedBy="penciler", cascade=CascadeType.REMOVE)
    public Collection<IssueEntity> getPenciledIssues() {
        return penciledIssues;
    }
}
