Howdy Ranchers!
Recently I've bumped into a topic about the purpose of DTO (
https://coderanch.com/t/472362/patterns/opinion-Data-Transfer-Objects-pattern) and few questions raised in my head.
So, let's assume that right now (in
EJB 3.1 world) we don't need a DTO but we can use JPA entities. In the pointed topic there is a following statement:
If you're not using remote interfaces, no need to use Transfer Object, end of story.
1. Isn't the DTO supposed to promote loosely coupled design? If I understand the above topic correctly, it implies that I can create a JPA Entity (i.e. in the controller code of the client UI) and pass it to the EJB business method.
Ok, but I think that in this case my view layer (controller and view) will be aware of changes made directly to the database (change in JPA entity), am I right? This isn't very nice...
2. Another case. Assume I have a
JBoss AS with my business logic and -- right beside -- a
Tomcat server with client UI. Both servers runs
on the same machine.
Does it mean that they run on the same JVM or on separate? Is it treated as a remote or local invocation?
If it's treated as a local access and we use JPA entities directly from the client than doesn't the Tomcat client UI application need to have a dependency on the JPA code to be able to run entities it should present / create? Once again it seems strange that client UI-only layer needs a dependency on the persistency layer...
So talking about the design - how would you cope with the above problems?
Thanks in advance for your help!
Cheers!