This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Peter, Neither is going to always be recommended over the other. A lot of it is preferences. Personally, I prefer property based access because it gives me the OO encapsulation. It's easier to develop that way up front than add it later.
Do note that you must use the same technique throughout your EJB. You can't use some field based and some property based.
Thank you Jeanne, but I thought that with field based access I received better encapsulation. Fields would be private, only entity manager could access them from outside. And I would write only necessary getters and setters for clients.
I am asking because I am about to start new project and there is no easy way to change my mind later.
I can also put my validation logic in setters methods. Only entity manager can by pass this logic. But I suppose that on DB is everything OK. If not there is possibility to put this logic into entity listeners.
author & internet detective