开发者

Superkey consists of three attributes - how to cope with Hibernate?

Consider a relation with开发者_JAVA技巧 a candidate key of three attributes:

Superkey consists of three attributes - how to cope with Hibernate?

I was wondering if someone could give me an example of a config file for Hibernate?


...
<class name="Topic" table="topics">
    ...
    <set name="candidatures" table="Topic_has_Count_has_Date">
        <key column="TOPIC_ID"/>
        <composite-element class="TopicCountDate">
            <parent name="topic"/>
            <many-to-one name="count" class="Count" column="COUNT_ID"/>
            <many-to-one name="date" class="Date" column="DATE_ID"/>
        </composite-element>
    </set>
</class>
<class name="Date" table="dates">
    ...
    <set name="candidatures" table="Topic_has_Count_has_Date">
        <key column="DATE_ID"/>
        <composite-element class="TopicCountDate">
            <parent name="date"/>
            <many-to-one name="count" class="Count" column="COUNT_ID"/>
            <many-to-one name="topic" class="Topic" column="TOPIC_ID"/>
        </composite-element>
    </set>
</class>
<class name="Count" table="counts">
    ...
    <set name="candidatures" table="Topic_has_Count_has_Date">
        <key column="COUNT_ID"/>
        <composite-element class="TopicCountDate">
            <parent name="count"/>
            <many-to-one name="date" class="Date" column="DATE_ID"/>
            <many-to-one name="topic" class="Topic" column="TOPIC_ID"/>
        </composite-element>
    </set>
</class>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜