Mansour wrote:

An alternative approach is that you don't allow persistent entities to be modified within your actions whatsoever and all updates are applied behind a service layer that performs reattachment and updates.
How do I do this (reattachment and updates)? Assuming I have a very big and complex entities.
The most appropriate approach depends mainly on the complexity of your entities and the separation of concerns you require.

OK, that's what I have in my business layer. Tere's a facade for my business layer. The actions can obtain a reference to this facade through the session by implemeting SessionAware.


In this case, at the layer interface you would manually transfer the relevant content of the persistent entities to simple beans created especially for the use-case. Your actions use the beans, not the entities. Updates from the beans are manually applied by your code to the persistent entities behind the layer (load, apply changes manually, persist). These simple beans are sometimes called Data Transfer Objects (DTOs), and by manually I mean you have to write code to explicitly apply the conversion and updates to and from the simple beans and persistent entities. This comes at great cost in terms of the amount of code and testing required as well as processing performance compared to the other approach. The advantage is that the layer can provide strict constraints on how data can be viewed and updated (good security), your business layer is COMPLETELY distinct and independent of the view (good when you have large teams or multiple views) and the business layer can easily be distributed (remote and/or clustered services). That's essentially the basis of EJB. If you ever use GWT you'll also take the same approach. I stress though, that's a lot more effort and the additional cost is not appropriate in most web applications.
Glad I could help,
Jeromy Evans



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to