Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Transient field

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic