• Post Reply Bookmark Topic Watch Topic
  • New Topic

Value Objects and relations design  RSS feed

 
Harm de Laat
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I made a J2EE application which uses entity beans. The weblayer uses a session facade session bean which lookups up entity beans and passes the information as value objects.
This works fine.
My ValueObjects also have relations defined.
For example:
Client 1 ---- n Address
In my JSP I can do:
<%
ClientValueObject client = request.getParameter("client");
out.println(client.getAddress().getStreetName());
%>
This also is great. But sometimes I don't need the Address class and just show the Client information in my JSP.
I made the SQL generated visuable in my JBoss console. I was shocked to see that so much SQL was generated.
When large queries are needed this realy slow's down my application.
I looked into the valueObject pattern. And saw that I can make several light-weight value objects, to get specificly needed values. Which causes less SQL beeing generated.
What is a good strategy for passing information between the EJB tier and the WEB tier?
Is it a good strategy to maintain relationships between value objects? Or are the some smarter ways of optimizing?
Thanks!
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes you need the value object relationships, sometimes you don't. One size does not fit all. Have special value objects for each purpose and only fetch back exactly what you need. Also, sometimes even the Session Bean/Entity Bean/Value Object is overkill, and you can employ the Fast Lane Reader to populate value objects directly from SQL inside a Session bean. It all comes down to using the right tool for the job.
Kyle
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!