aspose file tools*
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
Author

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
Bartender

Joined: Mar 07, 2007
Posts: 1278

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Field Based Persistence
 
Similar Threads
Annotations on instance declaration or get method using JPA in entities?
The difference between field-based access and property-based access
Enthuware question com.enthuware.ets.scbcd.v5.2.79
Answers of Sun's Free Proficiency Assessment
Dynamically build a javaBean