package br.com.fiap.entity;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "GIF")
public class Gif implements Serializable {

	private static final long serialVersionUID = 480069580562973503L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "idGif")
	private int idGif;

	@Column(name = "nome", length = 45)
	private String nome;

	@Column(name = "descricao", length = 200)
	private String descricao;

	@Column(name = "dataPublicacao")
	private transient LocalDate dataPublicacao;

	@Column(name = "caminho", length = 45)
	private String caminho;

	@ManyToMany(fetch = FetchType.EAGER, mappedBy = "gifs")
	private Set<Usuario> usuarios;

	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
	@JoinTable(name = "GIF_CATEGORIA", joinColumns = @JoinColumn(name = "idGif"), inverseJoinColumns = @JoinColumn(name = "idCategoria"))
	private Set<Categoria> categorias;

	public int getIdGif() {
		return idGif;
	}

	public void setIdGif(int idGif) {
		this.idGif = idGif;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public LocalDate getDataPublicacao() {
		return dataPublicacao;
	}

	public void setDataPublicacao(LocalDate dataPublicacao) {
		this.dataPublicacao = dataPublicacao;
	}

	public String getCaminho() {
		return caminho;
	}

	public void setCaminho(String caminho) {
		this.caminho = caminho;
	}

	public Set<Usuario> getUsuarios() {
		return usuarios;
	}

	public void setUsuarios(Set<Usuario> usuarios) {
		this.usuarios = usuarios;
	}

	public Set<Categoria> getCategorias() {
		if(categorias == null){
			categorias = new HashSet<>();
		}
		return categorias;
	}

	public void setCategorias(Set<Categoria> categorias) {
		this.categorias = categorias;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((caminho == null) ? 0 : caminho.hashCode());
		result = prime * result + idGif;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Gif)) {
			return false;
		}
		Gif other = (Gif) obj;
		if (caminho == null) {
			if (other.caminho != null) {
				return false;
			}
		} else if (!caminho.equals(other.caminho)) {
			return false;
		}
		if (idGif != other.idGif) {
			return false;
		}
		return true;
	}
	
}

@@ -645,26 +645,27 @@
 D = 
-480069580562973503
+2944518807918395130
 L;%0A%0A
@@ -871,16 +871,16 @@
  = 200)%0A
-
 %09private
@@ -895,24 +895,242 @@
 descricao;%0A%0A
+%09@Column(name = %22genero%22, length = 45)%0A%09private String genero;%0A%0A%09@Column(name = %22classificacaoEtaria%22, length = 45)%0A%09private String classificacaoEtaria;%0A%0A%09@Column(name = %22idioma%22, length = 45)%0A%09private String idioma;%0A%0A
 %09@Column(nam
@@ -2595,24 +2595,456 @@
 gorias;%0A%09%7D%0A%0A
+%09public String getGenero() %7B%0A%09%09return genero;%0A%09%7D%0A%0A%09public void setGenero(String genero) %7B%0A%09%09this.genero = genero;%0A%09%7D%0A%0A%09public String getClassificacaoEtaria() %7B%0A%09%09return classificacaoEtaria;%0A%09%7D%0A%0A%09public void setClassificacaoEtaria(String classificacaoEtaria) %7B%0A%09%09this.classificacaoEtaria = classificacaoEtaria;%0A%09%7D%0A%0A%09public String getIdioma() %7B%0A%09%09return idioma;%0A%09%7D%0A%0A%09public void setIdioma(String idioma) %7B%0A%09%09this.idioma = idioma;%0A%09%7D%0A%0A
 %09@Override%0A%09

Ajuste na entidade gif