Yes, I know why they are there...
At one point with some version of Orion way back when, failing to
initialize the fields to something caused an error (I don't remember
exactly what error) when the bean was persisted or activated or something
like that. Much of my code from which pieces of the examples were taken
didn't populate all fields in the bean, just the key field, in the create
method. This example, I believe, does not work that way (I would have to
check and don't remember off the top of my head).
So prehaps the need for this was long ago removed by a fix or upgrade. This
is an old example now. Mostly, the three examples I wrote, I feel, are
usefull for demonstrating how to make EJB 2.0 CMP work under Orion. Orion's
implementation veries a bit from the proposed final draft, so these
examples do whats needed to make the code work.
BTW, Joe and whoever else maintains OrionSupport.com, could you guys add my
other two examples to the site? I get many requests for these files from
people who said they looked there first...
Jim
--On Thursday, February 22, 2001 1:02 PM -0500 Tim Endres
<[EMAIL PROTECTED]> wrote:
> I am not certain about Jim's example. However, we use this style of code
> to null out "transient" fields that get filled in during the use of an
> entity bean. The problem is that these fields are not "cleared" between
> passivation and re-activation. Thus, you can have fields with invalid
> values from a pervious incantation of the bean. Clearing these fields
> solves that problem.
>
> tim.
>
>> I just read Arhcer's Test20Cmp example (posted on this list earlier on).
>> I am unaware of the need for the initToNull() method (see below); does
>> anyone know why its there - its is repeated in the later examples aswell.
>>
>> Well, I know at least one guy who knows... but if anyone else but Jim
>> himself knows, you are of course also very welcome to reply ;-). Thanks.
>>
>>
>> Randahl
>>
>>
>>
>> public String ejbCreate() {
>> trace("ejbCreate() entered");
>>
>> initToNull();
>>
>> setUserId("jarcher");
>> setFirstName("Jim");
>> setLastName("Archer");
>> setEmail("[EMAIL PROTECTED]");
>>
>> trace("ejbCreate() exiting");
>>
>> // In CMP, should return null.
>> return null;
>> }
>>
>>
>> //
>> private void initToNull()
>> {
>> trace("initToNull() entered");
>>
>> setUserId(null);
>> setFirstName(null);
>> setLastName(null);
>> setEmail(null);
>>
>> trace("initToNull() exiting");
>> }
>>
>>
>
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I -
I took the one less traveled by,
And that has made all the difference.
- Robert Frost, 1916