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="Publisher.findAll", query="SELECT p from PublisherEntity as p"),
	@NamedQuery(name="Publisher.findByName", query="SELECT p from PublisherEntity as p WHERE p.name = :name")
})

@Entity
@Table(name="PUBLISHER")
public class PublisherEntity {

    private Long id;
	
    private String name;
	
    private Collection<ComicEntity> comic = new ArrayList<ComicEntity>();

    @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 setComic(Collection<ComicEntity> comic) { this.comic = comic; }

    @OneToMany(mappedBy="publisher", cascade=CascadeType.REMOVE)
    public Collection<ComicEntity> getComic() { return comic; }
}
