Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing private fields vs. using annotated get method

 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just discovered today that you can access the private fields of another instance of the same class in a copying method:



Not sure if this is intended to be possible.

Anyway, my question. If the getter for field x was annotated with @Column (hibernate for example, mapping it to a db table column), would the copyFrom() method cause problems? Field x might not be initialized in the toBeCopied object (with fetchtype lazy). When just accessing the field, and NOT using the getter, the value of the field would not be obtained or would it?

Sorry I'm a hibernate noob. I guess I'll change the method copyFrom anyway just to be sure, but would still like to know if my doubt is valid.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic