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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:03:48+00:00 2026-05-11T20:03:48+00:00

I want to test my Dao Class using the SpringContextTests. In my method class

  • 0

I want to test my Dao Class using the SpringContextTests.
In my method class I extended the AbstractTransactionalJUnit4SpringContextTests in order for my test class to integrate with JUnit4. I have also set up the configurations and made the initialization and database clean up in the @Before and tearDown in the @After. My test class works perfectly.

My problem was, when I run my test class and the database is filled with data, the original data was not rolled back and my database is cleared. In the @Before method, I clear the database and populate data, thinking that I will be able to rollback it but its not.

Can anyone site an example that works and rollbacks information in the database.

ADDONS:
Every database manipulation in my test methods are rolled back. But the execution of super.deleteFromTables("person") in the @Before method did not rollback all the previous data from the database.

Spring rollbacks all the CRUD operations but the database clean up before the transaction do not rollback.

  • 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-11T20:03:48+00:00Added an answer on May 11, 2026 at 8:03 pm

    Thank you to all those who answered my question. I learned a lot from those answers but it didn’t solve my problem.
    I knew my test data does a transaction management and it does its job properly.
    The mistake is on my part.

    I forgot the lesson about database commands that when you execute a DDL statement after a DML statement, it will automatically commit the transaction. I executed a DDL after a DML by deleting all record and then ALTER the AUTO_INCREMENT of the table where in it will cause an auto-commit and delete all records of the table permanently.

    FIXING THAT SCENARIO SOLVED MY PROBLEM.

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

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer File -> Export Template -> Project Template This will then… May 11, 2026 at 9:07 pm
  • Editorial Team
    Editorial Team added an answer I partially solve this problem by switching to the another… May 11, 2026 at 9:07 pm
  • Editorial Team
    Editorial Team added an answer I use an ImageList to hold all my images, but… May 11, 2026 at 9:07 pm

Related Questions

I have an NHibernate Dao..lets call it MyClassDao for want of a better name.
I want to test my software on different Windows Operating Systems. I plan to
I'm new to TDD and xUnit so I want to test my method that
I own a total of one iPhones. I want to test my app on
I want to use php in console mode and create an environment to test

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.