Created
April 27, 2017 20:44
-
-
Save sidneydemoraes/b4bc7211f7daa79e0132df0cd5ba17ea to your computer and use it in GitHub Desktop.
TechTalk - Gradle + Spring Boot + Groovy - JPA Entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import br.com.smc.meurumo.domain.comercio.valueobject.CentroideEstabelecimento | |
import br.com.smc.meurumo.domain.comercio.valueobject.EnderecoEstabelecimento | |
import br.com.smc.meurumo.domain.ibge.entity.SetorCensitario | |
import javax.persistence.* | |
/** | |
* Entidade representando um estabelecimento comercial registrado no Brasil. | |
*/ | |
@Entity | |
@Table(name = "estabelecimentos") | |
public class Estabelecimento { | |
@Id | |
@Column(name = "cnpj", columnDefinition = "varchar(14)") | |
String cnpj | |
@Column(name = "razao_social") | |
String razaoSocial | |
@Column(name = "nome_fantasia") | |
String nomeFantasia | |
@Embedded | |
EnderecoEstabelecimento endereco | |
@ManyToOne | |
@JoinColumn(name = "id_natureza") | |
NaturezaDoEstabelecimento naturezaDoEstabelecimento | |
@Column(name = "data_abertura") | |
Date dataDeAbertura | |
@Column(name = "id_situacao") | |
Integer situacao | |
@Column(name = "data_situacao", columnDefinition = "datetime") | |
Date dataSituacao | |
@Column(name = "cmb") | |
Long cmb | |
@Embedded | |
CentroideEstabelecimento centroide | |
@ManyToMany(fetch = FetchType.LAZY) | |
@JoinTable(name = "cnpj_cnae", | |
joinColumns = @JoinColumn(name = "cnpj"), | |
inverseJoinColumns = @JoinColumn(name = "cod_cnae")) | |
Set<Cnae> listaDeCnaes | |
@ManyToOne(fetch = FetchType.LAZY) | |
@JoinTable(name = "estabelecimento_setor", | |
joinColumns = @JoinColumn(name = "cnpj"), | |
inverseJoinColumns = @JoinColumn(name = "setor_censitario")) | |
SetorCensitario setorCensitario | |
SituacaoDoEstabelecimento getSituacao() { | |
return SituacaoDoEstabelecimento.getType(this.situacao) | |
} | |
void setSituacao(SituacaoDoEstabelecimento situacaoDoEstabelecimento) { | |
this.situacao = situacaoDoEstabelecimento.getId(); | |
} | |
Long getCmb() { | |
return cmb ?: 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment