Java tutorial
/* * The MIT License * * Copyright 2012 Universidad de Montemorelos A. C. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package mx.edu.um.mateo.inventario.model; import java.math.BigDecimal; import java.util.Date; import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Version; import javax.validation.constraints.NotNull; import org.springframework.format.annotation.DateTimeFormat; /** * * @author J. David Mendoza <jdmendoza@um.edu.mx> */ @Entity @Table(name = "xfacturas_almacen") public class XFacturaAlmacen { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Version private Integer version; @Column(nullable = false, length = 64) private String folio; @Column(length = 128) private String comentarios; @NotNull @DateTimeFormat(pattern = "dd/MM/yyyy") @Temporal(TemporalType.DATE) @Column(nullable = false) private Date fecha; @Column(scale = 2, precision = 8, nullable = false) private BigDecimal iva = BigDecimal.ZERO; @Column(scale = 2, precision = 8, nullable = false) private BigDecimal total = BigDecimal.ZERO; @Column(name = "factura_almacen_id", nullable = false) private Long facturaAlmacenId; @Column(name = "estatus_id", nullable = false) private Long estatusId; @Column(name = "cliente_id", nullable = false) private Long clienteId; @Column(name = "almacen_id", nullable = false) private Long almacenId; @Temporal(TemporalType.TIMESTAMP) @Column(name = "date_created") private Date fechaCreacion; @Temporal(TemporalType.TIMESTAMP) @Column(nullable = false, name = "last_updated") private Date fechaModificacion; @Column(nullable = false, length = 64) private String creador; @Column(nullable = false, length = 64) private String actividad; public XFacturaAlmacen() { } /** * @return the id */ public Long getId() { return id; } /** * @param id * the id to set */ public void setId(Long id) { this.id = id; } /** * @return the version */ public Integer getVersion() { return version; } /** * @param version * the version to set */ public void setVersion(Integer version) { this.version = version; } /** * @return the folio */ public String getFolio() { return folio; } /** * @param folio * the folio to set */ public void setFolio(String folio) { this.folio = folio; } /** * @return the comentarios */ public String getComentarios() { return comentarios; } /** * @param comentarios * the comentarios to set */ public void setComentarios(String comentarios) { this.comentarios = comentarios; } /** * @return the fecha */ public Date getFecha() { return fecha; } /** * @param fecha * the fecha to set */ public void setFecha(Date fecha) { this.fecha = fecha; } /** * @return the iva */ public BigDecimal getIva() { return iva; } /** * @param iva * the iva to set */ public void setIva(BigDecimal iva) { this.iva = iva; } /** * @return the total */ public BigDecimal getTotal() { return total; } /** * @param total * the total to set */ public void setTotal(BigDecimal total) { this.total = total; } /** * @return the facturaAlmacenId */ public Long getFacturaAlmacenId() { return facturaAlmacenId; } /** * @param facturaAlmacenId * the facturaAlmacenId to set */ public void setFacturaAlmacenId(Long facturaAlmacenId) { this.facturaAlmacenId = facturaAlmacenId; } /** * @return the estatusId */ public Long getEstatusId() { return estatusId; } /** * @param estatusId * the estatusId to set */ public void setEstatusId(Long estatusId) { this.estatusId = estatusId; } /** * @return the clienteId */ public Long getClienteId() { return clienteId; } /** * @param clienteId * the clienteId to set */ public void setClienteId(Long clienteId) { this.clienteId = clienteId; } /** * @return the almacenId */ public Long getAlmacenId() { return almacenId; } /** * @param almacenId * the almacenId to set */ public void setAlmacenId(Long almacenId) { this.almacenId = almacenId; } /** * @return the fechaCreacion */ public Date getFechaCreacion() { return fechaCreacion; } /** * @param fechaCreacion * the fechaCreacion to set */ public void setFechaCreacion(Date fechaCreacion) { this.fechaCreacion = fechaCreacion; } /** * @return the fechaModificacion */ public Date getFechaModificacion() { return fechaModificacion; } /** * @param fechaModificacion * the fechaModificacion to set */ public void setFechaModificacion(Date fechaModificacion) { this.fechaModificacion = fechaModificacion; } /** * @return the creador */ public String getCreador() { return creador; } /** * @param creador * the creador to set */ public void setCreador(String creador) { this.creador = creador; } /** * @return the actividad */ public String getActividad() { return actividad; } /** * @param actividad * the actividad to set */ public void setActividad(String actividad) { this.actividad = actividad; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final XFacturaAlmacen other = (XFacturaAlmacen) obj; if (!Objects.equals(this.folio, other.folio)) { return false; } if (!Objects.equals(this.facturaAlmacenId, other.facturaAlmacenId)) { return false; } return true; } @Override public int hashCode() { int hash = 7; hash = 71 * hash + Objects.hashCode(this.id); hash = 71 * hash + Objects.hashCode(this.version); hash = 71 * hash + Objects.hashCode(this.folio); hash = 71 * hash + Objects.hashCode(this.facturaAlmacenId); return hash; } @Override public String toString() { return "XFacturaAlmacen{" + "folio=" + folio + ", facturaAlmacenId=" + facturaAlmacenId + '}'; } }