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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:52:54+00:00 2026-05-13T18:52:54+00:00

I have an application that I am currently writing that will use Spring and

  • 0

I have an application that I am currently writing that will use Spring and Hibernate. In my services layer I have injected a DAO that will do some very basic CRUD-ing actions. For grins, I have created a method annotated as follows:

@Transactional(readOnly = false, propogation=Propogation.REQUIRES_NEW)
public void doSomeWork(Dao dao, Entity e){
    //do some searching
    dao.persist(e);
    dao.findAll(Entity.clz);
}

The dao persist method looks like this:

public void persist(Entity e){
     session.saveOrUpdate(e); //This has already been built using a SessionFactory
}

The dao findAll method looks like this

public void findAll(Class clz) {
     session.createCriteria(clz).list();
}

Now, everything seems to run, OK. After I insert (persist) my object, I can see it using the findAll method (along with the new Primary Key ID that it was assigned by the Data Store), however, when the “doSomeWork” method completes, my data does not actually get persisted to the underlying datastore (Oracle 10g).

If, however, I remove the @Transactional annotations and use Hibernate’s session.getTransaction().begin() and session.getTransaction().commit() (or rollback), the code works as I would anticipate.

So, my underlying question would then be: Does Hibernate not actually use Spring’s transaction management for actual transaction management?

In my bean-config file I am declaring a TransactionManager bean, a SessionFactory bean, and I am also including in the config file.

What could I possibly be missing, aside for a better working-knowledge of Spring and Hibernate?

  • 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-13T18:52:54+00:00Added an answer on May 13, 2026 at 6:52 pm

    Ok, well, thanks to everyone who responded… it helped me to figure out what I am doing wrong…

    In my overzealous “proof-of-concepting” it never really dawned on me what was going on until I realized that my “simple java class with a main method that will be doing all my work” isn’t managed by spring, therefore no real transaction management. This will in no way behave as a product application would, being managed by an app-server with controller beans, services, etc.

    Then it dawned on me… “services”… I’m going to have a services layer, that’s where the transaction support will live. So, right as rain, I created a simple service bean (marked with @Transactional) and it works just as I would hope it would. So, I call methods on my service, which calls methods on my Dao and bam!!! it works.

    Thanks again to everyone who helped me to come to this conclusion.

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

Sidebar

Related Questions

I currently have some code that will produce a crash dump when my application
I currently have an application that inserts byte[] into our DB through the use
I'm currently writing an application that will control positioning of a measurement device. Because
I have an application that is currently running against a 32-bit SQL Server 2005
I have a web application that currently sends emails. At the time my web
I have a web application that's branded according to the user that's currently logged
I currently have an application that gets hit with over 20,000 users daily and
Currently I have an application that receives an uploaded file from my web application.
I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
I currently have an MS Access application that connects to a PostgreSQL database via

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.