Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7790609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:38:11+00:00 2026-06-01T21:38:11+00:00

I am reading this article on EJB 3.0, where the author describes an architecture

  • 0

I am reading this article on EJB 3.0, where the author describes an architecture where the service layer talks to the Entities through a DAO implemented as a stateless session bean.

I am trying to understand why do we need this additional layer.Why can the service layer not talk directly to the entities ? One thought that comes to my mind is – ease of testability. We can test the service layer easily by mocking the DAO’s.

Is this the only reason, or are there other reasons as well ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:38:12+00:00Added an answer on June 1, 2026 at 9:38 pm

    DAO is an abstraction over how to access database using objects. In the original practice of DAO, first there comes an interface defining the operations that you expect from your database:

    interface ModelDao {
      Model load(Long id);
      Long save(Model object);
    }
    

    Which can be generic or in any way that suits your design. Apart from the high degree of testability of interfaces, DAO pattern adds another advantage that now you can have different technologies implementing the same DAO pattern. Through time, you may need to switch from EJB to Spring JDBC or any other changes.

    While all this happens, the service layer still and only sees the data layer through DAO interface. The implementation is always encapsulated from service layer. Additionally, it also increases the testability of service layer through mechanisms such as mocking.

    If service layer directly starts to deal with data layer, it means that service layer becomes implementation specific which reduces modularity and coupling of concerns apart from making it harder to test the service layer only for the business logic.

    Last but not least, although it’s always the best to stick to the original practice, it depends on the size and intentions of your product/project to adopt the approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading this article about validating with service layer I have some doubts. First:
I've been reading this article from Valve that seems to explain the architecture of
Reading this article http://support.microsoft.com/kb/813878 I have a question: Where can I get ipseccmd.exe for
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
I was reading this article by Brandon Aaron here , about how jquery context
I was reading this article on Coding Horror: http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I went to the downloads
I was just reading this article and it mentions that some organization had an
just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
So , I've been reading this article: http://msdn.microsoft.com/en-us/library/aa290051%28VS.71%29.aspx And I would like to define

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.