0 Replies Latest reply on Nov 7, 2003 9:08 AM by rsczepan

    Problem with relation 1:1

    rsczepan

      I have two EnterpriseBeans wich are related 1:1 ans I have two tables in the database where are the Beans mapped on.
      In one of these tables I have an foreign key wich is the reference to the other Bean. The Type of the foreign key is Integer.
      But I have got allways a TransactionException. Postgres told me the typ of my foreign key column is integer and should be ascii. So I changed the typ of the foreign key column to text.
      The Result is: The whole serialized Object ist written in the foreign key column. But that is not what i want. I would like to have just an the key (integer) of the other table in that column.

      ejb-jar.xml:
      ....

      <ejb-name>Kunde</ejb-name>
      <local-home>satzmedia.sGrid.app.model.kunde.KundeLocalHome</local-home>
      satzmedia.sGrid.app.model.kunde.KundeLocal
      <ejb-class>satzmedia.sGrid.app.model.kunde.KundeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>KundeBean</abstract-schema-name>
      ..............
      <cmp-field><field-name>lieferanschrift</field-name></cmp-field>
      <primkey-field>kdid</primkey-field>
      ...........


      <ejb-name>Lieferanschrift</ejb-name>
      <local-home>satzmedia.sGrid.app.model.kunde.LieferanschriftLocalHome</local-home>
      satzmedia.sGrid.app.model.kunde.LieferanschriftLocal
      <ejb-class>satzmedia.sGrid.app.model.kunde.LieferanschriftBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>LieferanschriftBean</abstract-schema-name>
      <cmp-field><field-name>lieferid</field-name></cmp-field>
      ..........
      <primkey-field>lieferid</primkey-field>

      ......
      <ejb-relation>
      <ejb-relation-name>Kunde-Lieferanschrift</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Kunde hat Lieferanschrift
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Kunde</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>lieferanschrift</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Lieferanschrift gehoert einem Kunden
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Lieferanschrift</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      ......

      The Beans

      public interface KundeLocal extends EJBLocalObject {
      ........

      public LieferanschriftLocal getLieferanschrift();
      public void setLieferanschrift(LieferanschriftLocal la);
      }
      ......
      Thanks for your help
      Greetings Ralf