aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transient Annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Transient Annotation" Watch "Transient Annotation" New topic
Author

Transient Annotation

Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
According to the WhizLabs diagnostic exam, Question 25
WhizLabs wrote:A property not annotated as transient is surely persist.


Is it really true? What if a property that have a "private" access?
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
When field access is used, fields are persisted no matter what visibility they have for fields, but are not when they are annotated @Transient or the are transient (java keyword used for serialization).
For getter / setter access, only @Transient can be applied, and the methods must be public or protected.
(point 2.1.1 in the specs).
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
So, this question is asking about "property" access which means the getter/setter methods. In that case, if those methods has a private access, it wouldn't be persisted. Am I right? So is this an errata?
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Treimin Clark wrote:So, this question is asking about "property" access which means the getter/setter methods. In that case, if those methods has a private access, it wouldn't be persisted. Am I right? So is this an errata?

No, property does not mean getter/setter, it does mean field which has getter/setter.

I think that getter/setter need to be public or protected because JPA just doesn't support package-private and private, getter/setter.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transient Annotation
 
Similar Threads
valid combinations of Modifiers like static,native,transient etc
Annotations on instance declaration or get method using JPA in entities?
making a mostly anonymous Comparator be Serializable
how to exclude a class member from hibernate mapping?
Using @Transient Annotation in the POJO class