/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
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.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ryuuji
 */
@Entity
@Table(name = "tarjeta_debito")
@XmlRootElement
@NamedQueries({
  @NamedQuery(name = "TarjetaDebito.findAll", query = "SELECT t FROM TarjetaDebito t")
  , @NamedQuery(name = "TarjetaDebito.findById", query = "SELECT t FROM TarjetaDebito t WHERE t.id = :id")
  , @NamedQuery(name = "TarjetaDebito.findBySaldo", query = "SELECT t FROM TarjetaDebito t WHERE t.saldo = :saldo")
  , @NamedQuery(name = "TarjetaDebito.findByInsertedAt", query = "SELECT t FROM TarjetaDebito t WHERE t.insertedAt = :insertedAt")})
public class TarjetaDebito implements Serializable {

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarjetaDebito")
  private List<CompraTarjetaDebito> compraList;

  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Basic(optional = false)
  @Column(name = "id")
  private Integer id;
  @Basic(optional = false)
  @Column(name = "saldo")
  private int saldo;
  @Basic(optional = false)
  @Column(name = "inserted_at")
  @Temporal(TemporalType.TIMESTAMP)
  private Date insertedAt;
  @JoinColumn(name = "cliente", referencedColumnName = "id")
  @ManyToOne(optional = false)
  private Cliente cliente;
  @OneToMany(mappedBy = "tarjetaDebitoFrom")
  private List<TransferenciaTarjetaDebito> transferenciaFromList;
  @OneToMany(mappedBy = "tarjetaDebitoTo")
  private List<TransferenciaTarjetaDebito> transferenciaToList;
  @OneToMany(mappedBy = "tarjetaDebito")
  private List<DepositoTarjetaDebito> depositoList;
  @OneToMany(mappedBy = "tarjetaDebito")
  private List<GiroTarjetaDebito> giroList;

  public TarjetaDebito() {
  }

  public TarjetaDebito(Integer id) {
    this.id = id;
  }

  public TarjetaDebito(Integer id, int saldo, Date insertedAt) {
    this.id = id;
    this.saldo = saldo;
    this.insertedAt = insertedAt;
  }

  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public int getSaldo() {
    return saldo;
  }

  public void setSaldo(int saldo) {
    this.saldo = saldo;
  }

  public Date getInsertedAt() {
    return insertedAt;
  }

  public void setInsertedAt(Date insertedAt) {
    this.insertedAt = insertedAt;
  }

  public Cliente getCliente() {
    return cliente;
  }

  public void setCliente(Cliente cliente) {
    this.cliente = cliente;
  }

  @XmlTransient
  public List<TransferenciaTarjetaDebito> getTransferenciaFromList() {
    return transferenciaFromList;
  }

  public void setTransferenciaFromList(List<TransferenciaTarjetaDebito> transferenciaFromList) {
    this.transferenciaFromList = transferenciaFromList;
  }

  @XmlTransient
  public List<TransferenciaTarjetaDebito> getTransferenciaToList() {
    return transferenciaToList;
  }

  public void setTransferenciaToList(List<TransferenciaTarjetaDebito> transferenciaToList) {
    this.transferenciaToList = transferenciaToList;
  }

  @XmlTransient
  public List<DepositoTarjetaDebito> getDepositoList() {
    return depositoList;
  }

  public void setDepositoList(List<DepositoTarjetaDebito> depositoList) {
    this.depositoList = depositoList;
  }

  @XmlTransient
  public List<GiroTarjetaDebito> getGiroList() {
    return giroList;
  }

  public void setGiroList(List<GiroTarjetaDebito> giroList) {
    this.giroList = giroList;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof TarjetaDebito)) {
      return false;
    }
    TarjetaDebito other = (TarjetaDebito) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
      return false;
    return true;
  }

  @Override
  public String toString() {
    return "entities.TarjetaDebito[ id=" + id + " ]";
  }

  @XmlTransient
  public List<CompraTarjetaDebito> getCompraList() {
    return compraList;
  }

  public void setCompraList(List<CompraTarjetaDebito> compraList) {
    this.compraList = compraList;
  }

}
