简体   繁体   中英

Hibernate mapping

I got a table with a PK and a value "country", all my labels are definied in another table which has composite-ids.

Does anyone has an example for me how I can map my country value to the correct label in the other table?

mappings are bound on PK, if I'm not wrong.

  <class name="hibernate.P1" table="P1">

    <id name="id" type="int">
        <column name="LFNR" precision="7" scale="0" />
    </id>
    <property name="land" type="int" not-null="true">
        <column name="LAND" precision="1" scale="0" />
    </property>

<class name="hibernate.P5" table="P5">

    <composite-id name="Id" class="hibernate.P5Id">
        <key-property name="tab" type="string">
            <column name="TAB" length="4" />
        </key-property>
        <key-property name="lfnr" type="string">
            <column name="LFNR" length="4" />
        </key-property>
        <key-property name="usa" type="string">
            <column name="USA" length="4" />
        </key-property>
        <key-property name="hier" type="int">
            <column name="HIER" precision="2" scale="0" />
        </key-property>
        <key-property name="land" type="int">
            <column name="LAND" precision="3" scale="0" />
        </key-property>
        <key-property name="sart" type="string">
            <column name="SART" length="3" />
        </key-property>
    </composite-id>
    <property name="label" type="string">
      <column name="LABEL" length="50" />
    </property>


    .....

I can't change the layout of the db sadly.

由于不能保证对于P1中的给定行,只有一行会出现在P5表中,因此您应该包括一对多,即P1中的一组本身包含P5的一个元素。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM