I am currently working on a 3-tier application with Java-EE6 (GlassFish 3.1.2, MySQL Server 5.1 and Netbeans 7.1.1).
The project currently consists of 3 projects:
For updating the client's GUIs when entities are created/modified/deleted I decided to make use of JMS by implementing a Topic where each client subscribes on start-up and a message-driven bean on the EJB-container serves as publisher.
Now I face the following big issue:
This is a more design-related question & thus asking you if this is basically the right approach to design a 3-tier application with Java-EE6 ?
I want to avoid DTO/DAO if possible in order to keep complexity as low as possible and the application does not produce heavy network traffic.
Thanks for your advise in advance !
I solved the problem by passing the @Entity objects directly between all the layers. By activating static weaving (using eclipse-link as jpa provider) I was able to use lazy fetching for the heavy relations. In order to only fetch particular important relations from the client side, I use load groups to define the lazy relations that should be pre-fetched before serialized over the network which detaches the entity from the entity manager. vis-versa to send an entity to the server again, I just use EntityManager.merge(T) on the server side facade to put the entity back to managed state. This design works fine, even for very complex data hierarchies.