|
Problem(Abstract) |
Answers to questions on ejbCreate and ejbPostCreate |
|
|
|
Resolving the
problem |
Q: When initializing the persistent fields of an
entity EJB™ with different values in the ejbCreate and ejbPostCreate
callbacks, the database contains only the values set in ejbCreate. Why is
the EJB container overwriting the value in ejbPostCreate?
A: The method ejbCreate is called to allow an entity EJB to create
its instance and initialize its persistent data. However, the method
ejbPostCreate is called to allow the EJB instance to further initialize
itself and take advantage of the fact that it is now fully initialized;
for example, making use of the entityContext, the ejbObject, and so forth
(which are not valid in ejbCreate).
Q: Why is it that when creating two instances of the same entity
bean in succession, the first with 10 instance variables set, and the
second with only 5, that the uninitialized instance variables in the
second case have values from the previous create.
A: You must initialize the instance variables. If you do not
initialize them, the instance can contain any values (for example: the EJB
container does not initialize them) and by coincidence can retain the
previous values. This is quite likely because the EJB container uses the
same instance to service both the client requests. |
|
|
|
|
Cross Reference information |
Segment |
Product |
Component |
Platform |
Version |
Edition |
Application Servers |
Runtimes for Java Technology |
Java SDK |
|
|
|
|
|
|