I've got the following schema in DB (simplified)
MainTable(
ID primary key
SOMEFIELD
CODE_FK1 -- references OtherTable1 CODE (without declared foreign key)
CODE_FK2 -- references OtherTable2 CODE (without declared foreign key)
... Other fields used
)
OtherTable1(
CODE primary key
LABEL
... other fields not used
)
OtherTable2(
CODE primary key
LABEL
... other fields not used
)
I'm asking if there is any way to define my Entity for main table in order to use directly labels from my other tables, i.e without defining entities for these other table.
I cannot change the DB schema, which is really awful (there are labels/code couples everywhere, defined in multiples tables). And If it was possible, this solution would allow to keep my code simple, since I don't really need these other entities.
I guess it would result something like that:
@Entity
public class MainEntity{
@Id
private Integer ID;
@Column(name="SOMEFIELD")
private String SomeField;
@SomeAnnotation to Join CODE_FK_1 with OtherTable1.CODE
@SomeAnnotation like @Column(name="LABEL", table="OtherTable1")
private String Label1;
@SomeAnnotation to Join CODE_FK_1 with OtherTable1.CODE
@SomeAnnotation like @Column(name="LABEL", table="OtherTable1")
private String Label1;
}
Thanks by advance for your help!