2 Replies Latest reply on Jun 5, 2003 9:52 AM by jlewicki

    EJB and non-null foreign keys (X-Post)

    jlewicki Newbie

      I initially posted this in the EJB forum, but this seems like the better place...sorry for the cross post.

      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?