简体   繁体   English

使用外键名称休眠多对一键

[英]Hibernate many-to-one key with foreign key name

Using Hibernate 3.2.3 GA with hbm.xml files. Hibernate 3.2.3 GA与hbm.xml文件一起使用。

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). hibernate将使用一些随机ID(例如FKD40DC872B67B3502)自动在表格上生成FK

How can I set the name of the respective FK with my own cutomer FK_ID name ? 如何使用自己的用户FK_ID名称设置相应FK的名称?

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 覆盖hbm.xml并尝试重新格式化或执行,它将在运行时更新它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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