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 7809749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:32:09+00:00 2026-06-02T03:32:09+00:00

I have been googling for several hour now trying to find an example on

  • 0

I have been googling for several hour now trying to find an example on how to write a service method that doesn’t use Springs Hibernate Template while using a DAO interface. Something that is also confusing me is what happens when I put the @Transactional annotation in the service layer as opposed the DAO. Are the Service methods/DAO interfaces interchangeable?

Here is an example where the @Transactional is in the DAO

Here is one with the @Transactional in the Service Layer but using hibernate templates

Thanks for your help!

  • 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-02T03:32:10+00:00Added an answer on June 2, 2026 at 3:32 am

    The Spring documentation recommends avoiding HibernateTemplate completely, and use the Hibernate API directly instead:

    NOTE: As of Hibernate 3.0.1, transactional Hibernate access code can
    also be coded in plain Hibernate style. Hence, for newly started
    projects, consider adopting the standard Hibernate3 style of coding
    data access objects instead, based on
    SessionFactory.getCurrentSession().

    And the @Transactional annotation should always be put on methods of the service layer. This is the layer that demarcates transactions.

    Read http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#orm-session-factory-setup to understand how to setup a session factory. Once done, the session factory can be injected in your DAOs:

    @Repository
    public class MyDAO {
        @Autowired
        private SessionFactory sessionFactory;
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been Googling a problem that I have with trying to integrate the
So i have been googling/binging trying to find an answer on this but drawing
I have been googling for a while now but can find anywhere or a
Have been trying to encrypt an xml file to a string so that I
I have been googling and stackoverflowing for the last two hours and couldn't find
I have been googling a lot about this, but I can't find a specific
I have been googling around a bit and can't seem to find an solution.
i have been googling since morning for an answer that meets what i need
I have been googling about this issue for hours, and I'm stumped. Im trying
I have been googling for quite a long time but still find no solution.

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.