I don't have a definite answer for this odd behavior, but I've noticed the
same thing.
This seems to happen anytime you don't initialize the data fields of your
entity bean in the
ejbCreate() method.

The same behavior will result if you do the following:
Say you have an Entity bean called MyEntity.
Get a particular MyEntity object (let's refer to it as 'A') by using
findByPrimaryKey, then create a new MyEntity object via a create method
(refer to as 'B').

If entity object B does not initialize its data fields, they will be
populated with the data
from entity object A.

It seems to be the case that un-initialized data fields are populated with
in-memory data from the most recent entity object.  I'm not sure if this
behavior would be the same if, for instance, A was passivated before B was
created.  <shrug>

Is it an established practice to initialize all persistent data fields to
default (or empty) values?


joe



I have a test program that creates entity beans with just their primary key
information, then sets each of their data fields, and finally deletes them.
 I run this and everything works just fine.  But if I stop the test in a
debugger after the creation step (and before I set the data fields), I
notice that the data fields have values in them also!  It doesn't appear to
be total garbage.  It looks like data from a previous run of the test.  Is
this expected behavior?  Is the app server or the database caching stuff
and when it sees the same primary key information it automatically
populates the data fields?

I've even tried deleting the rows in the database that represent the beans
with SQL statements instead of deleting the beans as entity beans.  Same
result.

I'm using jBoss 2.0 FINAL running under jdk1.3 with Hypersonic database.

- Larry
Larry Kline
[EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]

Reply via email to