0 Replies Latest reply on Jun 4, 2003 1:40 PM by jlewicki

    Entity beans and non-null foreign keys

    jlewicki

      Hi all

      This is probably a silly question, but I could use some help. I have a 1-1 relationship between two tables, Clients and Addresses. The relationship is modeled as a foreign key (AddressID) in the Clients table that points to a row in the Addresses table. The database prohibits null values in the AddressID field (i.e. each client *must* have an address).

      My question is this: if the relationship is modeled using EJB 2.0 relationships, how do I create a new client EJB? In ejbCreate() I am prohibited from setting relationship fields (as per spec, that must be done in ejbPostCreate() ). But without setting the AddressID, the ejbCreate() for the client ejb fails, because null values are not allowed.

      I feel Im probably missing something obvious here. Is it fair to say that all foreign key fields must allow nulls to work with ejbs?

      Thanks!
      -John