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:

enter image description here

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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -