Rev 106 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.GeneratedValue; |
||
| 8 | import javax.persistence.GenerationType; |
||
| 9 | import javax.persistence.Id; |
||
| 10 | import javax.persistence.JoinColumn; |
||
| 11 | import javax.persistence.OneToOne; |
||
| 12 | import javax.persistence.Table; |
||
| 13 | import javax.persistence.Transient; |
||
| 14 | import javax.validation.constraints.NotNull; |
||
| 15 | |||
| 16 | import org.hibernate.annotations.ForeignKey; |
||
| 17 | |||
| 195 | espaco | 18 | import br.com.ec.core.interfaces.Alterar; |
| 19 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 20 | import br.com.ec.core.util.VerificadorUtil; |
||
| 106 | espaco | 21 | |
| 22 | @Entity |
||
| 23 | @Table(name="sec_empresa", schema="sc_sec") |
||
| 24 | public class Empresa implements Serializable { |
||
| 25 | |||
| 26 | private static final long serialVersionUID = 1L; |
||
| 27 | |||
| 28 | private Long codigo; |
||
| 29 | private Pessoa pessoa; |
||
| 30 | |||
| 31 | public Empresa() {} |
||
| 32 | |||
| 33 | public Empresa(Long codigo) { |
||
| 34 | this.codigo = codigo; |
||
| 35 | } |
||
| 36 | |||
| 37 | @Id |
||
| 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 39 | @Column(name="cod_empresa", nullable=false) |
||
| 40 | public Long getCodigo() { |
||
| 41 | return codigo; |
||
| 42 | } |
||
| 43 | public void setCodigo(Long codigo) { |
||
| 44 | this.codigo = codigo; |
||
| 45 | } |
||
| 46 | |||
| 47 | @OneToOne |
||
| 48 | @ForeignKey(name="fk_empresa_pessoa") |
||
| 49 | @NotNull(message="Obrigatório informar a pessoa", groups={Cadastrar.class, Alterar.class}) |
||
| 50 | @JoinColumn(name="seq_pessoa", referencedColumnName="seq_pessoa") |
||
| 51 | public Pessoa getPessoa() { |
||
| 52 | return pessoa; |
||
| 53 | } |
||
| 54 | |||
| 55 | public void setPessoa(Pessoa pessoa) { |
||
| 56 | this.pessoa = pessoa; |
||
| 57 | } |
||
| 58 | |||
| 59 | @Transient |
||
| 60 | public String getNomeDaPessoa() { |
||
| 61 | return VerificadorUtil.naoEstaNulo(pessoa) ? pessoa.getNome() : null; |
||
| 62 | } |
||
| 63 | |||
| 64 | } |