JPA OneToMany with composite keys in parent and children -
i have 2 tables represent authorizations users manage applications on given offices. 1 table has composite pk of office , user , holds information those, other has composite key of office, user , applicationid (table 2 holds no other information)
+---------------+ +---------------+ | table1 | | table2 | +---------------+ +---------------+ | - userid | 1 n | - userid | | - officeid | <-------> | - officeid | | <other data> | | - applicid | +---------------+ +---------------+
how represent in jpa? @ moment have this:
@data @embeddable public class table1_pk implements serializable { private bigdecimal officeid; private string userid; } @data @embeddable public class table2_pk implements serializable { @embedded private table1_pk table1pk; private int applicid; }
and entities: @entity public class table1 implements serializable { @embeddedid private table1_pk table1id; }
@entity public class table2 implements serializable { @embeddedid private table2_pk table2id; }
is right far? how can represent onetomany relation 2 table have?
the key field names same on both tables (so userid called "userid" on both table1 , table2 in db, table2 has field more application code)
Comments
Post a Comment