• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Transient field

 
Ranch Hand
Posts: 856
  • 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?
 
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: 856
  • 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.
 
Oh the stink of it! Smell my tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic