Question

I was going through an EJB 3.1 book (O'Reilly, Andrew Lee Rubinger and Bill Burke), there the author is mentioning that (these are not the exact words in the book, this is my own understanding of the text):

in SFSB when its becoming activated (after coming out of passivated pool), serialized objects, unlike their original norm, will not return the default values like int will not guaranteed to return 0 and object is not guaranteed to return null

Is my understanding correct? If it's true, why EJB have this behavior?

Original post on http://www.coderanch.com/t/546765/java-EJB-SCBCD/certification/why-serialization-unpredictable-SFSB#2481285

Was it helpful?

Solution

Per spec that is only applicable to transient fields.

From the specifications -- O'Reilly did not design EJBs (just saying ...) :

"While the container is not required to use the Serialization protocol for the Java programming language to store the state of a passivated session instance, it must achieve the equivalent result. The one exception is that containers are not required to reset the value of transient fields during activation[12]. Declaring the session bean’s fields as transient is, in general, discouraged." [EJB 3.1 - 4.2.1 - emphasis mine]

edit:

Btw, the answer to your question is also in the EJB specification:

"The restrictions on the use of transient fields ensure that containers can use Java Serialization during passivation and activation."

EJB 3.1 spec (mirror/pdf)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top