jQuery in Action, 3rd edition
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Field Based Persistence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Field Based Persistence" Watch "Field Based Persistence" New topic

Field Based Persistence

nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
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

Joined: Mar 07, 2007
Posts: 1294

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.

I agree. Here's the link: http://aspose.com/file-tools
subject: Field Based Persistence
It's not a secret anymore!