Chandra kumar wrote:

> ...

 >

> Back to my question again, Let's say we set the relationship value in 
>ejbPostCreate() as specified in the spec. What if the relationship(forignkey) field 
>is set as not null in child table and DB insert happening after ejbCreate(), insert 
>will fail. I think I'm missing something here, because I still don't seem to 
>understand significance of the statement in the spec that says "do not set the 
>cmr-fields in ejbCreate()"


Two issues here:

(1) The spec is taking a 'logical' view that before ejbCreate returns, the
     entity does not exist so you cannot enter it into relationships at that
     time.

(2) Having foreign key references that are defined as "not null" will
     generally be prone to causing constraint violations in some
     situations. Whether inserts are deferred (or for that matter, ordered)
     in such a way as to prevent foreign key constraint violations is not
     covered by the spec, but it is a quality of implementation issue.

     The spec does not guarantee that any EJB 2.0 CMP implementation will
     be able to work with arbitrary database-level constraints that you
     might have defined. The spec doesn't even require support for foreign
     keys at all!


> I humbly seek help on this to understand better.
>
> Thanks,
> Chandra
>
> On Thu, 31 Jan 2002 10:09:51 +1300, Evan Ireland <[EMAIL PROTECTED]> wrote:
>
>
>>Chandra kumar wrote:
>>
>>
>>>Section 10.5.2 of EJB 2.0 spec states the following:-
>>>
>>>"....... The entity Bean Provider must not attempt to modify the values of 
>cmr-fields in an ejbCreate<METHOD(...) method; this should be done in the 
>ejbPostCreate<METHOD(...) method instead. ......"
>>>
>>>I've tried my best to understand the above. But I could not succeed.
>>>Here are my questions (note: when we have strict DB constraints in place):
>>>
>>>1. How the above statement holds good, if we want set the relationship value in 
>child's ejbPostCreate(), If DB insert is issued after ejbCreate().
>>>
>>
>>That's up to the CMP implementation. Sybase EAServer (by default) will do
>>an 'insert' after ejbCreate and will do an 'update' after ejbPostCreate
>>(of course if no fields have changed, the 'update' can be skipped).
>>
>>
>>
>>>2. Let's say if DB insert is deferred to end of ejbPostCreate(), then we cannot 
>create child object(s) in ejbPostCreate() of Parent.
>>>
>>
>>That depends on whether your database schema has foreign key constraints that
>>will break if the insert is deferred.
>>
>>
>>
>>>If this is something very obvious, it'd probably irritate some to see a long mail 
>with examples. So I defer that to you.
>>>
>>>Any help would be greatly appreciated.
>>>
>>>Thanks for time and consideration,
>>>Chandra
>>>
>>>===========================================================================
>>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>>>of the message "signoff EJB-INTEREST".  For general help, send email to
>>>[EMAIL PROTECTED] and include in the body of the message "help".
>>>
>>>
>>>
>>>
>>>
>>
>>--
>>_______________________________________________________________________________
>>
>>Evan Ireland            Sybase EAServer Engineering         [EMAIL PROTECTED]
>>                          Wellington, New Zealand                +64 4 934-5856
>>
>>==========================================================================
>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>>of the message "signoff EJB-INTEREST".  For general help, send email to
>>[EMAIL PROTECTED] and include in the body of the message "help".
>>
>>
>
>


--
_______________________________________________________________________________

Evan Ireland            Sybase EAServer Engineering         [EMAIL PROTECTED]
                           Wellington, New Zealand                +64 4 934-5856

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to