/*
 * 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.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 = "cuenta_corriente")
@XmlRootElement
@NamedQueries({
  @NamedQuery(name = "CuentaCorriente.findAll", query = "SELECT c FROM CuentaCorriente c")
  , @NamedQuery(name = "CuentaCorriente.findById", query = "SELECT c FROM CuentaCorriente c WHERE c.id = :id")
  , @NamedQuery(name = "CuentaCorriente.findBySaldo", query = "SELECT c FROM CuentaCorriente c WHERE c.saldo = :saldo")
  , @NamedQuery(name = "CuentaCorriente.findByInsertedAt", query = "SELECT c FROM CuentaCorriente c WHERE c.insertedAt = :insertedAt")})
public class CuentaCorriente implements Serializable {

  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 = "cuentaCorriente")
  private List<DepositoCuentaCorriente> depositoList;
  @OneToMany(mappedBy = "cuentaCorrienteFrom")
  private List<TransferenciaCuentaCorriente> transferenciaFromList;
  @OneToMany(mappedBy = "cuentaCorrienteTo")
  private List<TransferenciaCuentaCorriente> transferenciaToList;
  @OneToMany(mappedBy = "cuentaCorriente")
  private List<GiroCuentaCorriente> giroList;

  public CuentaCorriente() {
  }

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

  public CuentaCorriente(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<DepositoCuentaCorriente> getDepositoList() {
    return depositoList;
  }

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

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

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

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

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

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

  public void setGiroList(List<GiroCuentaCorriente> 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 CuentaCorriente)) {
      return false;
    }
    CuentaCorriente other = (CuentaCorriente) 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.CuentaCorriente[ id=" + id + " ]";
  }
  
}
