package com.eyrolles.model;

import java.util.Collection;

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;

import com.fasterxml.jackson.annotation.JsonBackReference;

@Entity
@Table(name="souscategories")
public class SousCategorie {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private String nom;
@ManyToOne
@JsonBackReference
private Categorie categorie;
@OneToMany(mappedBy="sousCategorie")
@JsonBackReference
private Collection<Livre> livres;
public SousCategorie() {
	super();
}
public SousCategorie(String nom, Categorie categorie) {
	super();
	this.nom = nom;
	this.categorie = categorie;
}
public int getId() {
	return id;
}
public void setId(int id) {
	this.id = id;
}
public String getNom() {
	return nom;
}
public void setNom(String nom) {
	this.nom = nom;
}
public Categorie getCategorie() {
	return categorie;
}
public void setCategorie(Categorie categorie) {
	this.categorie = categorie;
}

public Collection<Livre> getLivres() {
	return livres;
}
public void setLivres(Collection<Livre> livres) {
	this.livres = livres;
}
@Override
public String toString() {
	return "SousCategorie [id=" + id + ", nom=" + nom +  "]";
}
@Override
public boolean equals(Object obj) {
	if (this == obj)
		return true;
	if (obj == null)
		return false;
	if (getClass() != obj.getClass())
		return false;
	SousCategorie other = (SousCategorie) obj;
	if (categorie == null) {
		if (other.categorie != null)
			return false;
	} else if (!categorie.equals(other.categorie))
		return false;
	if (nom == null) {
		if (other.nom != null)
			return false;
	} else if (!nom.equals(other.nom))
		return false;
	return true;
}







}
