aspose file tools*
The moose likes Object Relational Mapping and the fly likes Web application design concerns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Web application design concerns" Watch "Web application design concerns" New topic
Author

Web application design concerns

Tomas Toss
Greenhorn

Joined: Sep 06, 2011
Posts: 7
Hi ranchers!

I have recently started studying frameworks such as EJB, JSF and JPA. To learn these techniques I have decided to implement a web portal for a recreational badminton leauge. Via the portal, the players should be able to post and analyze results. As I started to implement the application I have started to wonder if my application design is "correct", and if not, what is the "correct" way to implement such an application.
At the moment, my application is basically structured in the following way:

web page (JSF) <---> Service bean (Managed bean, often ViewScoped) <---> Session bean (DAO) <---> Entity (JPA)

Is this a good application structure?

Question/Reflection 1: How should lazy loading of collections be handled with this scheme?
(The application contains many 1 --> N relations, e.g. Division|1 --> N|Team and Team|1 --> M|GameSeries)
From what I have gathered, there are primarily two techniques to handle this. Either by using the extended transaction scope with stateful DAO:s, or creating queries which fetches the collections eagerly (join left fetch) with stateless DAO:s.
I have gotten the impression that you should avoid the stateful beans to the greatest extent possible to avoid performance issues. This is perhaps not relevant for my current application, since it's a very small one. But I don't want to learn bad habits.


Question/Reflection 2: Where do I put the business logic?
At the moment I have put the business logic inside the service beans. However, sometimes this feels non-intuitive. Take the Game (entity) for example. It contains the fields homePlayer (entity), awayPlayer (entity) and the gameResult. To decide which player that won the game, the application calls a method in the GameService bean. This feels a bit akward to me. If I for instance want to decide a winner of a game from the DivisionService bean (to calculate the division standings), I have to declare a GameService bean inside it.
A more intuitive solution would be to implement this functionality inside the Game entity itself. But then the separation of concerns is somewhat lost.
What is the best practice to solve this?

Best regards
Tomas




lavnish lalchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 79
Hi Tomas
I am not sure if there is a need to use JPA and EJB in same app , or if there is some extra advantage one gains by using the two in same app.
JSF also gives you session scoped beans , so why use EJB Session bean ??

more shortly


lavnish.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web application design concerns