Question

J'ai deux table à relever à l'aide du fichier HBM.

Le scénario est comme suit

Le tableau B a un pk composite.

Tableau B

a1 (pk) A2 (pk) A3 (pk) foo bar

========

Tableau A a une clé primaire et est une clé étrangère du tableau B

Tableau A

a1 (pk, fk) hanche Hop

========

Ceci un à plusieurs relations de la table A à b.

Quelqu'un peut-il m'aider avec le mappage de fichiers HBM?

Je suis en train de noter wot j'ai essayé.

pour table B

<class>
<composite-id name="XXXX" class=".....">
        <key-property name="a1" column="a1" type="int"/>
        <key-property name="a2" column="a2" type="int"/>
        <key-property name="a3" column="a3" type="int"/>
    </composite-id>

    <property name="foo" column="foo" type="java.lang.Float"></property>    
    <property name="bar" column="bar" type="java.lang.Float"></property>
    </class>

pour table A

Cartographie d'hibernate normale.

Comment rejoindre les deux tables?

Était-ce utile?

La solution

Une solution de contournement pourrait être enfaitement de biens de propriété pour sortir du compositeid

<class class="B">
  <property name="a1_again" column="a1" insert="false" update="false"/>

  <bag name="As" class="A">
    <key property-ref="a1_again"></key>
    ...
  </bag>
</class>

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top