Rev 450 |
Rev 485 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
package br.com.ec.domain.model;
import java.io.Serializable;
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.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.ForeignKey;
import br.com.ec.core.interfaces.Alterar;
import br.com.ec.core.interfaces.Cadastrar;
import br.com.ec.core.util.VerificadorUtil;
@
Entity
@Table
(name=
"sec_notafiscal_produto", schema=
"sc_sec")
public class NotaFiscalProduto
implements Serializable {
private static final long serialVersionUID = 1L
;
private Long sequencial
;
private NotaFiscal notaFiscal
;
private Produto produto
;
private Integer quantidade
;
@Id
@SequenceGenerator
(name =
"sq_notafiscalproduto")
@GeneratedValue
(strategy = GenerationType.
IDENTITY)
@Column
(name=
"seq_notafiscalproduto", nullable=
false)
public Long getSequencial
() {
return sequencial
;
}
public void setSequencial
(Long sequencial
) {
this.
sequencial = sequencial
;
}
@ManyToOne
@ForeignKey
(name=
"fk_notafiscalproduto_notafiscal")
@JoinColumn
(name =
"seq_nota_fiscal", referencedColumnName=
"seq_nota_fiscal", insertable=
true, updatable=
false, nullable=
false)
public NotaFiscal getNotaFiscal
() {
return notaFiscal
;
}
public void setNotaFiscal
(NotaFiscal notaFiscal
) {
this.
notaFiscal = notaFiscal
;
}
@ManyToOne
@ForeignKey
(name=
"fk_notafiscalproduto_produto")
@JoinColumn
(name =
"seq_produto", insertable=
true, updatable=
false, nullable=
false)
public Produto getProduto
() {
return produto
;
}
public void setProduto
(Produto produto
) {
this.
produto = produto
;
}
@NotNull
(message =
"Parâmetro obrigatório não preenchido: Quantidade de produtos", groups =
{Cadastrar.
class, Alterar.
class})
@Column
(name=
"qtd_produto")
public Integer getQuantidade
() {
return quantidade
;
}
public void setQuantidade
(Integer quantidade
) {
this.
quantidade = quantidade
;
}
@Transient
public Long getSequencialDaNotaFiscal
() {
return VerificadorUtil.
naoEstaNulo(notaFiscal
)? notaFiscal.
getSequencial() :
null;
}
@Transient
public Long getSequencialDoProduto
() {
return VerificadorUtil.
naoEstaNulo(produto
)? produto.
getSequencial() :
null;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result +
((sequencial ==
null) ? 0 : sequencial.
hashCode());
return result
;
}
@
Override
public boolean equals
(Object obj
) {
if (this == obj
)
return true;
if (obj ==
null)
return false;
if (getClass
() != obj.
getClass())
return false;
NotaFiscalProduto other =
(NotaFiscalProduto
) obj
;
if (sequencial ==
null) {
if (other.
sequencial !=
null)
return false;
} else if (!sequencial.
equals(other.
sequencial))
return false;
return true;
}
}