From my junit test, I call a simple method to clear the 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(); }
ClearTable is as follows:
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 pretty simple things, however my console output doesn't go further:
deleting db contents
I'm not sure why exactly simple delete from classname
can cause such problems. The program just hangs for 10 minutes without glitches or junit test results.
Edit
However, I highlighted a problem for the clearTable () method, which moved it to the code and freezes as soon as it enters! I'm not quite sure why, from the information I found on the Internet, my method seems to be correct from what I see. But it must be this method. I put it in my @BeforeClass and the test just froze when it got to it.
The bottom line has a problem with the clearTable () method. You can not imagine that: (
EDIT 2
tracked the problem to the executeupdate part of the command for some reason, which just shrinks when it gets to:
ParseUtil.encodePath (string, boolean): 100
source share