Thanks for your reply. Let me rephrase my question a bit. Suppose we have a PersonServiceFacade
, that has a getPersonById(...)
method. Now when I call that method from my View/Controller layer, e.g. from a JSF/CDI managed bean, what I get is a detached Person
entity. I'm fine with that; I just let the user manipulate the values within the object via a form and merge and persist the Person
object as the user presses the "save" button.
However, sometimes people tell me it is not good to work with detachted entities directly. Those people either create DAO objects or manipulate the entities only via methods on the PersonServiceFacade
. (E.g. setPersonName(Person person, String newName)
) I don't see much harm in manipulating detached objects, as soon as you don't forget to merge them. On the other hand, creating extra DAO objects or similar strategies seems to introduce much boilerplate / repeated code.
What's your opinion on this? Can you give me some good arguments to settle this discussion once and for all?