java - Hibernate Primary Foreign Key field -
i have 2 simple tables in database. like:
t1 t2 id number primary key id number primary key & foreign key t1 value varchar value varchar
how hibernate entity t2 like? tried @embeddable class containing t1 mapped-class object doesn't work. thanks.
upd: full use case when need such structure below: have business entities tables, containing data specific business users, , company table id , value fields too, , want create companytobentity table, containing data company can access object.(objects row of bus.entities).
so think structure fits case.
pic describing better:
you can try unidirectional one-to-one association vi primary key association
-
t1 mapping
@id @column(name="id") private integer id;
t2 mapping
@onetoone(cascade=cascadetype.all) @primarykeyjoincolumn private t1 t1;
for more reference visit here, example based on hbm.xml
Comments
Post a Comment