Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Field Based Persistence

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does field based persistence mean having annotated public entity variables without getters and setters?

I tried making annotated private entity instance variables and providing getters /setters. It works this way too. So I am now not sure what exactly is meant by field based persistence?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nitin,

as you probably now that @Id annotation decides whether to use field or getter/setter based persistence management. If you use field based the members don't have to be public as the entity manager also has access to inject member values even if they are declared private.

I'd personally recommend using the getter/setter based approach though because this allows you to be more flexible if you want to do some additional things in your getter/setter which wouldn't be possible with direct field access.

Marco
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic