Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transient Annotation  RSS feed

 
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!