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

  • Home
  • SEARCH
  • 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 7609427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:10:05+00:00 2026-05-31T01:10:05+00:00

My web application is written using Spring MVC + Hibernate. My model is Customer

  • 0

My web application is written using Spring MVC + Hibernate.

  • My model is “Customer” entity POJO.
  • I have got a DAO object “CustomerDAO”, its method “saveCustomer(c)” contains the code interacting with Hibernate;
  • Then I created a “CustomerService with a “saveCustomer(c)” method who simply pass the customer object to the dao for saving;
  • Finally there are “CustomerController” and customer.jsp, who are responsible for the view layer, the jsp’s form fields are bound to a Customer object on the controller side. The controller calls the service.

I saw a lot of applications follow this (best) practice but I’m wondering why I would need a service layer.

Maybe it’s useful for decoupling purpose: I can show a universal facade to the controllers and inject into the service HibernateDAO, GaeDAO, MyDAO, and so on…. But I could do that without the service, too: using an interface.

I also tought: validation. I’ll make my Customer validation in the service but…. it’s much more convenient to validate in Spring controller.

Help me understand the concept please 🙂

  • 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-05-31T01:10:07+00:00Added an answer on May 31, 2026 at 1:10 am

    You don’t need a service layer. However it helps you to

    • Decouple your components
    • You can enforce specific business rules in your service layer which should be agnostic to your repository
    • Let a service facade one or more repositories. Let’s consider the following sample
    class Service {
      private DatabaseBarRepo barRepo;
      private DatabaseFooRepo fooRepo;
    
      @Transactional
      public void serviceRoutine() {
         barRepo.doStuff();
         fooRepo.doStuff();
      }
    }
    

    Here we let two separate repositories take part in the same transaction. This is specific for databases albeit the principles are valid for other systems as well.

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

Sidebar

Related Questions

I have my web application written in Spring MVC. It is quite simple app
In a web application written using spring-MVC, I want to allow users to change
I have a Spring MVC based web application. There are many custom tags written
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321
I have web application written in java using Eclipse. It has just one servlet
I have an asp.net web application written in C# using a SQL Server 2008
I have a web application, written in ColdFusion, which periodically starts using 100% of
I have a forum like web application written in Asp.net MVC. I'm trying to
I am using spring security 3.0.5 in my web application based on Spring MVC.
I'm interested in porting an existing application which was written using Spring/Struts2/Hibernate to GAE.

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.