• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Session Bean + DAO

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am desinging an application where I am using Fast Lane Reader Pattern (Stateless Session Bean + DAO) for reports. We have created seperate custom DTOs (Value objects) for each report. Now my question is - where should we place the logic to create the DTOs. Should we create the DTO in the DAO layer and return it to the session bean or create it in the session bean and fill it there. According to Core J2EE patterns, the logic to create the DTO should go in the DAO. I guess this is a good idea when we have to create domain DTOs (the data from one single table), where one single call to the backend will return all the data related to the DTO. But in our case where we have to fire a seperate sql for each DTO field, I think, the logic should go in Session Bean. I am a bit confused. I would like to hear some expert views on that.
Thanks
Tomchi
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create the DTO in DAO.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it would be best to keep *all* SQL stuff inside the DAO layer.
 
Tomchi Tang
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your Input. Actually we want to show different reports which have details like
- Total no of Sellers
- Total no of purchase/non-purchase items and their values
- Total no of categorized/non-categorized items and their values
....
....
This information is also required in other reports. I can think of following possible solutions:
1) Create a generic ReportDAO which have queries used in all the reports. When we need to show a specific report, we can call the ReportDAO from our session bean, fill the XXXReportDTO and send it back to the client.
2) Create a generic ReportDAO which have queries used in all the reports. In addition to these queries, DAO also have functions to create, populate and return specific DTO. In this case, Generic ReportDAO will aslo work as what you called "Super DAO". It interact with session bean and internally use query functions to create and populate DTOs.
3) Similar to (2) where the superDAO will be a seperate Factory Class.
4) Create report specific DAOs which have a method to create report specific DTO.
Pls. suggest which option is the best.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about starting out with the one big report DAO and refactoring afterwards if deemed necessary?
 
reply
    Bookmark Topic Watch Topic
  • New Topic