content: package br.com.alevhvm.adotai.avaliacao.model;
  
  import java.io.Serializable;
  import java.time.LocalDateTime;
  
  import br.com.alevhvm.adotai.ong.model.Ong;
  import br.com.alevhvm.adotai.usuario.model.Usuario;
  import jakarta.persistence.Column;
  import jakarta.persistence.Entity;
  import jakarta.persistence.FetchType;
  import jakarta.persistence.GeneratedValue;
  import jakarta.persistence.GenerationType;
  import jakarta.persistence.Id;
  import jakarta.persistence.JoinColumn;
  import jakarta.persistence.ManyToOne;
  import jakarta.persistence.Table;
  import jakarta.persistence.UniqueConstraint;
  import jakarta.validation.constraints.Max;
  import jakarta.validation.constraints.Min;
  import lombok.EqualsAndHashCode;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  import lombok.Setter;
  
  @Getter
  @Setter
  @NoArgsConstructor
  @EqualsAndHashCode(callSuper = false)
  @Entity
  @Table(name = "avaliacao",
          uniqueConstraints = {
              @UniqueConstraint(columnNames = {"usuario_id", "ong_id"}) //garante que o usuario avalie apenas uma vez a ONG
          }
  )
  public class Avaliacao implements Serializable {
      
      @Id
      @Column(name = "id", nullable = false, unique = true)
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "usuario_id", nullable = false)
      private Usuario usuario;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "ong_id", nullable = false)
      private Ong ong;
  
      @Min(1)
      @Max(5)
      @Column(name = "nota", nullable = false)
      private Integer nota;
  
      @Column(name = "comentario", length = 1000)
      private String comentario;
  
      @Column(name = "data_criacao", nullable = false, updatable = false)
      private LocalDateTime dataCriacao;
  }
  