package com.peetz.library.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.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="SHELFBOARD")
public class ShelfboardEntity {
	private Long id;
	
	private String title;
	
	private BookshelfEntity bookshelf;
	
	private Collection<ShelfObjectEntity> objects = new ArrayList<ShelfObjectEntity>();
	
	@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; }

	@ManyToOne
	public BookshelfEntity getBookshelf() {
		return bookshelf;
	}

	public void setBookshelf(BookshelfEntity bookshelf) {
		this.bookshelf = bookshelf;
	}

	@OneToMany(mappedBy="shelfboard", cascade=CascadeType.REMOVE)
	public Collection<ShelfObjectEntity> getObjects() {
		return objects;
	}

	public void setObjects(Collection<ShelfObjectEntity> objects) {
		this.objects = objects;
	}

}
