I have two tables in postgresql:
schema1.imovel
idt_imovel | int
cod_imovel | string
nome_imovel | string
etc...
schema2.declaration
idt_declaracao | int
cod_imovel | string
status | string
etc...
The two tables contain the cod_imovel
column but there is no relationship between the tables.
I have the two tables mapped with hibernate, the Imovel
and Declaracao
classes.
For each entity of class Imovel
, I need to know the status of the declaration.
Is there any way to "force" a relationship in hibernate even without the relationship in the database?
I need something like this:
@Entity
@Table(name = "imovel", schema = "schema1")
public class Imovel extends GenericModel {
@Id
@Column(name="idt_imovel")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "imovel_seq")
@SequenceGenerator(name = "imovel_seq", sequenceName = "integracao_lotes.imovel_idt_imovel_seq", allocationSize = 1)
public Integer id;
@Column(name="nome_imovel")
public String nomeImovel;
@Column(name="cod_imovel")
public String codigo;
@relacionamentofake //aqui precisa existir uma forma de mapear a tabela declaracao
public Declaracao declaracao