我的 hbm.xml 文件是这样的:
<hibernate-mapping>
<class name="pojopackage.WordhelperWordusage" table="WORDHELPER_WORDUSAGE" schema="SOZANA">
<composite-id name="id" class="pojopackage.WordhelperWordusageId">
<key-property name="idwh" type="java.lang.Integer">
<column name="IDWH" />
</key-property>
<key-property name="idwu" type="java.lang.Integer">
<column name="IDWU" />
</key-property>
<key-property name="type" type="java.lang.Integer">
<column name="TYPE" />
</key-property>
</composite-id>
<many-to-one name="wordhelper" class="pojopackage.Wordhelper" update="false" insert="false" fetch="select">
<column name="IDWH" />
</many-to-one>
<many-to-one name="wordusage" class="pojopackage.Wordusage" update="false" insert="false" fetch="select">
<column name="IDWU" />
</many-to-one>
</class>
但是我有两个 POJO 类,它们是“WordhelperWordusage.java”和“WordhelperWordusageId.java”,所以我很困惑,我应该如何处理这些类?如何实施?提前致谢! 更新
我确实喜欢这个
wordhelper_wordusage.save(wordhelper);
wordhelper_wordusage.save(wordusage);
session.save(wordhelper);
session.save(wordusage);
session.save(wordhelper_wordusage);
但它给了我这样的例外:
Hibernate: select max(ID) from SOZANA.WORDFORM
Hibernate: select max(ID) from SOZANA.WORDHELPER
Exception in thread "main" org.hibernate.id.IdentifierGenerationException:
ids for this class must be manually assigned before calling save(): pojopackage.WordhelperWordusage