我完成了本教程,并配置了 Hibernate API 和映射: https ://netbeans.org/kb/docs/web/hibernate-webapp.html
(我正在使用带有“示例”数据库而不是 MySQL 的 JavaDB API)
但我有一个问题:生成的 hbm.xml 文件不包含任何外键映射。(没有一对多或多对一的属性)
这是一个示例类和映射文件。RoleID 应该是 ROLE 表 ID 字段的外键。
我试图编辑 hibernate.reveng.xml 文件以强制创建 FK - 像这样:
<table name="USERS">
<foreign-key constraint-name="ROLE_USER_FK" foreign-table="ROLE">
<column-ref local-column="roleid" foreign-column="id" />
<many-to-one property="roleid" />
</foreign-key>
</table>
但它不起作用。