Rev 195 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 195 | Rev 470 | ||
|---|---|---|---|
| Line 9... | Line 9... | ||
| 9 | import javax.persistence.Id; |
9 | import javax.persistence.Id; |
| 10 | import javax.persistence.JoinColumn; |
10 | import javax.persistence.JoinColumn; |
| 11 | import javax.persistence.ManyToOne; |
11 | import javax.persistence.ManyToOne; |
| 12 | import javax.persistence.SequenceGenerator; |
12 | import javax.persistence.SequenceGenerator; |
| 13 | import javax.persistence.Table; |
13 | import javax.persistence.Table; |
| 14 | import javax.persistence.Transient; |
- | |
| 15 | import javax.validation.constraints.NotNull; |
14 | import javax.validation.constraints.NotNull; |
| 16 | 15 | ||
| 17 | import org.hibernate.annotations.ForeignKey; |
16 | import org.hibernate.annotations.ForeignKey; |
| 18 | 17 | ||
| 19 | import br.com.ec.core.interfaces.Alterar; |
18 | import br.com.ec.core.interfaces.Alterar; |
| 20 | import br.com.ec.core.interfaces.Cadastrar; |
19 | import br.com.ec.core.interfaces.Cadastrar; |
| 21 | import br.com.ec.core.util.VerificadorUtil; |
- | |
| 22 | 20 | ||
| 23 | @Entity |
21 | @Entity |
| 24 | @Table(name="sec_notafiscal_produto", schema="sc_sec") |
22 | @Table(name="sec_notafiscal_produto", schema="sc_sec") |
| 25 | public class NotaFiscalProduto implements Serializable { |
23 | public class NotaFiscalProduto implements Serializable { |
| 26 | 24 | ||
| 27 | private static final long serialVersionUID = 1L; |
25 | private static final long serialVersionUID = 1L; |
| 28 | 26 | ||
| 29 | private Long sequencial; |
27 | private Long sequencial; |
| 30 | private NotaFiscal notaFiscal; |
28 | private NotaFiscal notaFiscal; |
| 31 | private Produto produto; |
- | |
| - | 29 | private CompraProduto compraProduto; |
|
| 32 | private Integer quantidade; |
30 | private Integer quantidade; |
| 33 | 31 | ||
| 34 | @Id |
32 | @Id |
| 35 | @SequenceGenerator(name = "sq_notafiscalproduto") |
33 | @SequenceGenerator(name = "sq_notafiscalproduto") |
| 36 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
34 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| Line 39... | Line 37... | ||
| 39 | return sequencial; |
37 | return sequencial; |
| 40 | }
|
38 | }
|
| 41 | public void setSequencial(Long sequencial) { |
39 | public void setSequencial(Long sequencial) { |
| 42 | this.sequencial = sequencial; |
40 | this.sequencial = sequencial; |
| 43 | }
|
41 | }
|
| 44 | - | ||
| - | 42 | ||
| 45 | @ManyToOne |
43 | @ManyToOne |
| 46 | @ForeignKey(name="fk_notafiscalproduto_notafiscal") |
44 | @ForeignKey(name="fk_notafiscalproduto_notafiscal") |
| 47 | @JoinColumn(name = "seq_nota_fiscal", referencedColumnName="seq_nota_fiscal", insertable=true, updatable=false, nullable=false) |
45 | @JoinColumn(name = "seq_nota_fiscal", referencedColumnName="seq_nota_fiscal", insertable=true, updatable=false, nullable=false) |
| 48 | public NotaFiscal getNotaFiscal() { |
46 | public NotaFiscal getNotaFiscal() { |
| 49 | return notaFiscal; |
47 | return notaFiscal; |
| 50 | }
|
48 | }
|
| 51 | public void setNotaFiscal(NotaFiscal notaFiscal) { |
49 | public void setNotaFiscal(NotaFiscal notaFiscal) { |
| 52 | this.notaFiscal = notaFiscal; |
50 | this.notaFiscal = notaFiscal; |
| 53 | }
|
51 | }
|
| 54 | 52 | ||
| - | 53 | @ManyToOne |
|
| - | 54 | @ForeignKey(name="fk_notafiscalproduto_compraproduto") |
|
| - | 55 | @JoinColumn(name = "seq_compraproduto", referencedColumnName="seq_compraproduto", insertable=true, updatable=false, nullable=false) |
|
| - | 56 | public CompraProduto getCompraProduto() { |
|
| - | 57 | return compraProduto; |
|
| - | 58 | }
|
|
| - | 59 | public void setCompraProduto(CompraProduto compraProduto) { |
|
| - | 60 | this.compraProduto = compraProduto; |
|
| - | 61 | }
|
|
| - | 62 | ||
| - | 63 | /*
|
|
| 55 | @ManyToOne |
64 | @ManyToOne
|
| 56 | @ForeignKey(name="fk_notafiscalproduto_produto") |
65 | @ForeignKey(name="fk_notafiscalproduto_produto")
|
| 57 | @JoinColumn(name = "seq_produto", insertable=true, updatable=false, nullable=false) |
66 | @JoinColumn(name = "seq_produto", insertable=true, updatable=false, nullable=false)
|
| 58 | public Produto getProduto() { |
67 | public Produto getProduto() {
|
| 59 | return produto; |
68 | return produto;
|
| 60 | }
|
69 | }
|
| 61 | public void setProduto(Produto produto) { |
70 | public void setProduto(Produto produto) {
|
| 62 | this.produto = produto; |
71 | this.produto = produto;
|
| 63 | }
|
72 | }
|
| - | 73 | */
|
|
| 64 | 74 | ||
| 65 | @NotNull(message = "Parâmetro obrigatório não preenchido: Quantidade de produtos", groups = {Cadastrar.class, Alterar.class}) |
75 | @NotNull(message = "Parâmetro obrigatório não preenchido: Quantidade de produtos", groups = {Cadastrar.class, Alterar.class}) |
| 66 | @Column(name="qtd_produto") |
76 | @Column(name="qtd_produto") |
| 67 | public Integer getQuantidade() { |
77 | public Integer getQuantidade() { |
| 68 | return quantidade; |
78 | return quantidade; |
| 69 | }
|
79 | }
|
| 70 | public void setQuantidade(Integer quantidade) { |
80 | public void setQuantidade(Integer quantidade) { |
| 71 | this.quantidade = quantidade; |
81 | this.quantidade = quantidade; |
| 72 | }
|
82 | }
|
| 73 | 83 | ||
| - | 84 | /*
|
|
| 74 | @Transient |
85 | @Transient
|
| 75 | public Long getSequencialDaNotaFiscal() { |
86 | public Long getSequencialDaNotaFiscal() {
|
| 76 | return VerificadorUtil.naoEstaNulo(notaFiscal)? notaFiscal.getSequencial() : null; |
87 | return VerificadorUtil.naoEstaNulo(notaFiscal)? notaFiscal.getSequencial() : null;
|
| 77 | }
|
88 | }
|
| 78 | 89 |
|
|
| 79 | @Transient |
90 | @Transient
|
| 80 | public Long getSequencialDoProduto() { |
91 | public Long getSequencialDoProduto() {
|
| 81 | return VerificadorUtil.naoEstaNulo(produto)? produto.getSequencial() : null; |
92 | return VerificadorUtil.naoEstaNulo(produto)? produto.getSequencial() : null;
|
| 82 | }
|
93 | }
|
| - | 94 | */
|
|
| 83 | 95 | ||
| 84 | @Override |
96 | @Override |
| 85 | public int hashCode() { |
97 | public int hashCode() { |
| 86 | final int prime = 31; |
98 | final int prime = 31; |
| 87 | int result = 1; |
99 | int result = 1; |