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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:00:16+00:00 2026-05-25T21:00:16+00:00

Does anybody knows a way to achieve the following flow for testing DAOs: Run

  • 0

Does anybody knows a way to achieve the following flow for testing DAOs:

  • Run SQL script to create common DB setup (insert data into all tables)
  • Test DAO1
  • Test DAO2
  • …
  • Clean-up DB Data created in Step 1

Using Spring, Hibernate, JUnit, Maven stack.

I understand that best practice would be that we create data for each test DAO (@BeforeClass) and clean-up the same after all tests are done (@AfterClass).

But in our case there are just too many dependencies between different database tables (client’s legacy DB 🙁 can’t do anything about that at the moment). Populating each table with test data requires data in many other tables as well. So, creating data individually for each DAO would be very tough and time consuming. So, we really need to create DB test data only once.

I’ve created test data using static block in BaseDAO (extended by each DAO Test Class) – which obviously runs only once. But problem how to clean-up the same when all tests (of all DAO Test subclasses) get completed. An @AfterClass teardown method in base class will run each time after a DAO Test class completes.

Please advise.

  • 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-25T21:00:17+00:00Added an answer on May 25, 2026 at 9:00 pm

    If you’re using Maven, a good option is to use DBUnit. It lets you export test data from the database (or just write it in XML), to be imported for your tests. It has a Maven plugin which will do what you require.

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

Sidebar

Related Questions

Does anybody know of a way to create a DataSet such that when I
Does anybody know of an automated way of telling whether a PHP script is
Does anybody knows a way to change the font size of the editor tabs
Does anybody know a way to embed an icon in a Python script such
Does anybody know a way to create a keyboard shortcut for the button 'Expand
Does anybody knows if there is a simple way to change this var colorTransform:NewColorTransform;
Does anybody knows, if there is a way to use a property that is
Does anybody know a way to make the axis fixed on a CPTXYGraph when
Does anybody know offhand the way to tell whether I'm being called statically (Classname::function)
Does anybody know of a way of generating a boxplot in R with a

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.