简体   繁体   中英

Hibernate many-to-one key with foreign key name

Using Hibernate 3.2.3 GA with hbm.xml files.

Having such a many-to-one key

<key-many-to-one name="attachment" column="attachmentId"
                     class="com.attachment.Attachment"/>

hibernate will auto-generate a FK on the table with some random ID (like FKD40DC872B67B3502).

How can I set the name of the respective FK with my own cutomer FK_ID name ?

Please , see

This link

<one-to-one name="product" foreign-key="productId" 
           cascade="all-delete-orphan" lazy="false" />

Override the hbm.xml and try to remab or execute , it will update them on run time

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