Evan,

<I asked>
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. ......"

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().
<\I asked>

<Evan wrote>
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).
<\Evan 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()"

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".
>

===========================================================================
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