• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient field

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restore transient fields using the information in non-transient fields.

this statement is from enthuware. Can any one refer this statement to specifications?
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The specification says that transient fields are not preserved for passivation, and they are not required to be reset to their default values for activation. So, they have to be reinitialized in @PostActivate if they are to be used later. The statement you are quoting does not come explicitly from the specs, it is just common sense I would say - if you are to reinitialize the transient fields to meaningful values, you probably use some non-transient fields to help you. This is the same for serialization / deserialization, when you want transient fields to be set to anything meaningful. You could of course set it randomly, not set it at all, whatever yuo like. But, using other non-transient fields is most common.
About passivation and transient fields - the very last paragraph from section 4.2.1, pages 64 / 65:

The Bean Provider must assume that the content of transient fields may be lost between the PrePas-
sivate and PostActivate notifications. Therefore, the Bean Provider should not store in a
transient field a reference to any of the following objects: SessionContext object; environ-
ment JNDI naming context and any its subcontexts; business interfaces; home and component inter-
faces; EntityManager interface; EntityManagerFactory interface; UserTransaction
interface.

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 excep-
tion is that containers are not required to reset the value of transient fields during activation.
Declaring the session bean’s fields as transient is, in general, discouraged.


Hope this helps,
Raf.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Raf for your reply.

Well it can be a just common sense wording's only. But not totally true.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic