我有表格A和B与表格快捷方式相关但是,我收到此错误
org.hibernate.MappingException: An association from the table A refers to an unmapped class: Shortcut
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1112)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1062)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1146)
当我在对象A或B中将快捷方式设为null或者删除对象A或B并保存或删除时,快捷方式不会在表格快捷方式中删除。
我认为我必须在快捷方式中设置关系,但因为有两个表我不知道如何做到这一点。
table A
id - int - Primary key
description - String
.
.
**id_shortcut - int - Foreing key table shortcut - id**
table B
id - int - Primary key
description - String
.
.
**id_shortcut - int - Foreing key table shortcut - id**
表格快捷方式 id - int - 主键 description - 字符串
a.hbm.xml
.
.
<many-to-one cascade="all" class="Shortcut" fetch="join" name="shortcut">
<column name="ID_SHORTCUT" not-null="false"/>
</many-to-one>
b.hbm.xml
.
.
<many-to-one cascade="all" class="Shortcut" fetch="join" name="shortcut">
<column name="ID_SHORTCUT" not-null="false"/>
</many-to-one>
shortcut.hbm.xml
<hibernate-mapping>
<class name="Shortcut" table="ris_SHORTCUT">
<id name="id" type="java.lang.Long">
<column name="ID" sql-type="NUMBER(19)"/>
<generator class="sequence">
<param name="sequence">RIS_SHORTCUT_SEQ</param>
</generator>
</id>
<property generated="never" lazy="false" name="key1" type="java.lang.String">
<column name="KEY1" not-null="true" sql-type="VARCHAR2(20)"/>
</property>
<property generated="never" lazy="false" name="key2" type="java.lang.String">
<column name="KEY2" not-null="true" sql-type="VARCHAR2(1)"/>
</property>
</class>
</hibernate-mapping>