简体   繁体   中英

Hibernate xml mapping one key to two other tables

I've got the 3 following tables:

    Table1:
    keyA; keyB; keyC; (primary key is A+B+C)

    Table2:
    keyA; keyC; (primary key is A+C)

    Table3:
    keyA; keyB; (primary key is A+B)

With hibernate xml mapping I want for my Table1 to be linked to both Table2 and Table3 using these keys. Can I do that?

只需通过可连接表1 描述表2和3之间的多对多链接。cf此示例: 在此处输入链接描述

Well in your first Table Table1 you have (primary key is A+B+C) , and you are asking:

With hibernate xml mapping I want for my Table1 to be linked to both Table2 and Table3 using these keys. Can I do that?

Yes, you can do that, but your two other tables Table2 and Table3 must have all the keys/columns that represent the Primary key of Table1 , so they must contain the three columns keyA, keyB and keyC along with a OneToMany mapping between Table1 and both Table2 and Table3 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM