问题:有两个表名为 specialday 和规则。在规则表中,一个名为specialrule的列引用了特殊日期表并想要制作rule.hbm.xml文件的方式,以便当我从表中获取规则对象时,它还将获取关联的特殊对象。 在这里,我写下了 specialdaydata.hbm.xml 和 rule.hbm.xml
<composite-id name="specialDayIdData" class="SpecialDayIdData">
<key-property name="name" column="NAME" type="string"/>
<key-property name="specialRule" column="SPECIAL_RULE" type="string"/>
</composite-id>
<property name="type" type="java.lang.Integer">
<column name="TYPE" sql-type="NUMERIC" not-null="true"/>
</property>
---other column
------
</class>
<id name="rule" column="RULESTRING" type="string">
<generator class="assigned"/>
</id>
<property name="specialRule" type="string">
<column name="SPECIAL_RULE" sql-type="VARCHAR(64)" not-null="false"/>
</property>
<!--specialRule Refer SpecialDayData -->
<many-to-one >
Stuck over here
</many-to-one>
</class>
答案 0 :(得分:0)
<many-to-one
name="specialRule"
column="SPECIAL_RULE"
class="ClassName"
not-null="true" lazy="true"
>
在Rule.hbm.xml文件中使lazy =“true”