2 Replies Latest reply on May 6, 2004 9:05 AM by hustenbolschen

    Foreign Key Problem

    hustenbolschen

      I have a problem about foreign keys.

      I have two tables
      company and contact_person
      and the company_id (pk of company) shall be the foreign key of the table contact_person....This foreign key is defined to be NOT NULL.....so every contact_person belongs to a company.

      I think my question is about the EJB specs.

      when I try to create a contact_person i get two different mistakes.

      When I set the company_id in the ejbCreate() it says "a cmr-field cannot be set in the ejbCreate(); this should be done in the ejbPostCreate();
      As the EJB-Specs say

      if I do it in the ejbPostCreate() I got an SQL.Exception which says company_id cannot be null....(as I defined it in the table).....

      so is there a workaround?
      Don`t define foreign keys as NOT NULL?

      If code is needed just tell me, and I will post it