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

@NamedQueries({
    @NamedQuery(name="InsertSet.findAll", query="SELECT i from InsertEntity as i"),
    @NamedQuery(name="InsertSet.findById", query="SELECT i from InsertEntity as i WHERE i.id = :id"),
    @NamedQuery(name="InsertSet.findByName", query="SELECT i from InsertEntity as i WHERE i.name = :name")
})

@Entity
@Table(name="INSERTSET")
public class InsertEntity {
    private Long id;
    private String name;
    private ManufacturerEntity manufacturer;
    private BaseSetEntity baseSet;
    private Collection<SportCardEntity> sportCard = new ArrayList<SportCardEntity>();

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

    @ManyToOne
    public ManufacturerEntity getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(ManufacturerEntity manufacturer) {
        this.manufacturer = manufacturer;
    }

    @ManyToOne
    public BaseSetEntity getBaseSet() {
    	return baseSet;
    }

    public void setBaseSet(BaseSetEntity baseSet) {
    	this.baseSet = baseSet;
    }

    @OneToMany(mappedBy="insert", cascade=CascadeType.REMOVE)
    public Collection<SportCardEntity> getSportCard() {
        return sportCard;
    }

    public void setSportCard(Collection<SportCardEntity> sportCard) {
        this.sportCard = sportCard;
    }
}
