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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:49:54+00:00 2026-05-22T02:49:54+00:00

From my junit test I’m calling a simple method to clear my table: @AfterClass

  • 0

From my junit test I’m calling a simple method to clear my table:

    @AfterClass  
public static void runAfterClass() {   
    //Clear db contents after tests         
    // NOTE this clears ALL data from the table
    try {
        System.out.println("deleting db contents");
        HibFunction.clearTable();
    } catch (Exception e) {
        System.out.println("Couldnt delete db contents"); 
        e.printStackTrace();
    }

The clearTable looks like:

    public static void clearTable()
{
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = null;
    try{
    transaction = session.beginTransaction();
    session.createQuery("delete from metadataPoC.hib.TestHib").executeUpdate();
    transaction.commit();
    }catch (HibernateException e) {
        transaction.rollback();
        e.printStackTrace();
    } finally {
        session.close();
    }


}

All fairly simple stuff however my console output goes no further than:

deleting db contents

I am unsure why exactly a simple delete from classname

can cause such issues. The programme has just been hanging for 10mins with no failure or result from the junit test.

Edit

However I’ve isolated the problem to the clearTable() method moved it around in the code and as soon as it entered, hangs!
I’m not exactly sure why exactly, from the info I’ve found online my method seems correct from what I can see. But it has to be this method. I placed it in my @BeforeClass and the test just frozen when it got to it.

Bottom line there is a problem with the clearTable() method. Thou I’ve no idea what 🙁

EDIT 2

tracked down the problem to the executeupdate portion of the command for whatever reason it just stalls once it gets to the:

ParseUtil.encodePath(String, boolean) line: 100

  • 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-22T02:49:55+00:00Added an answer on May 22, 2026 at 2:49 am

    It’s probably a deadlock between transaction of clearTable() method and transaction of the test method.

    Make sure that you complete (commit or rollback) all transactions when leaving the test method.

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

Sidebar

Related Questions

Such a junit : @Test public void testA { //some code here... } @Test
I have a simple JUnit test in Eclipse. public class HelloTest extends TestCase {
I have the following JUnit test: @Test public void testRunLocalhost() throws IOException, InterruptedException {
I'm calling this function from a jUnit test case with the following information: //
Running the Java Compiler from a JUnit test is pretty simple using the Java
This is a snippet from my Robolectric enabled JUnit test class : @Before public
I have the following JUnit test. The method that I'm testing is quite simple,
We're finally migrating our unit test code base from JUnit 3 to JUnit 4.
I am attempting to run a JUnit Test from a Java Class with: JUnitCore
While I run my simple Junit test for testing the the Jpa/Dao configuration I

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.