package com.peetz.tradingcards.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="Manufacturer.findAll", query="SELECT m from ManufacturerEntity as m"),
    @NamedQuery(name="Manufacturer.findByName", query="SELECT m from ManufacturerEntity as m WHERE m.name = :name")
})

@Entity
@Table(name="MANUFACTURER")
public class ManufacturerEntity {
	
	private Long id;
	private String name;
	private Collection<BaseSetEntity> baseSets = new ArrayList<BaseSetEntity>(); 
	private Collection<ParallelSetEntity> parallelSets = new ArrayList<ParallelSetEntity>(); 
	private Collection<InsertEntity> inserts = new ArrayList<InsertEntity>(); 

	@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;
	}

	@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
	public Collection<BaseSetEntity> getBaseSets() {
		return baseSets;
	}

	public void setBaseSets(Collection<BaseSetEntity> baseSets) {
		this.baseSets = baseSets;
	}

	@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
	public Collection<ParallelSetEntity> getParallelSets() {
		return parallelSets;
	}

	public void setParallelSets(Collection<ParallelSetEntity> parallelSets) {
		this.parallelSets = parallelSets;
	}

	@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
	public Collection<InsertEntity> getInserts() {
		return inserts;
	}

	public void setInserts(Collection<InsertEntity> inserts) {
		this.inserts = inserts;
	}
}
