You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Sy...@swisscom.com on 2002/12/20 16:46:10 UTC

[PB] associations and storing objects

Hello,

I'm using OJB PB and I have implemented 1:1, 1:N and M:N associations.
Retrieving and deleting objects in all of them work very well.

But I have some problem about storing and updating objects.
I give you an example:

I have a table A and a table B. There is a 1:1 association between them.
The table A have a B_FK foreign key that contain a primary key value of table B.
OK.
Now I want to store a new A object.
My question is:
Do I have to insert a B_FK value or could I have a NULL value in this field?
In other words: is the B_FK value mandatory?

Thank you all
Regards
Sylvain

Re: [PB] associations and storing objects

Posted by Laurie Harper <zo...@holoweb.net>.
Sylvain.Thevoz@swisscom.com wrote:

> Do I have to insert a B_FK value or could I have a NULL value in this 
> field?
> In other words: is the B_FK value mandatory?


Depends how you define it in your database schema. If it is defined as 
NOT NULL then it can't have a NULL value and so is mandatory. If you 
don't specify such a constraint, it wont be enforced.

L.