Guest User

Untitled

a guest
Jul 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @AfterClass
  2. public static void runAfterClass() {
  3. //Clear db contents after tests
  4. // NOTE this clears ALL data from the table
  5. try {
  6. System.out.println("deleting db contents");
  7. HibFunction.clearTable();
  8. } catch (Exception e) {
  9. System.out.println("Couldnt delete db contents");
  10. e.printStackTrace();
  11. }
  12.  
  13. public static void clearTable()
  14. {
  15. Session session = HibernateUtil.getSessionFactory().openSession();
  16. Transaction transaction = null;
  17. try{
  18. transaction = session.beginTransaction();
  19. session.createQuery("delete from metadataPoC.hib.TestHib").executeUpdate();
  20. transaction.commit();
  21. }catch (HibernateException e) {
  22. transaction.rollback();
  23. e.printStackTrace();
  24. } finally {
  25. session.close();
  26. }
  27.  
  28.  
  29. }
  30.  
  31. deleting db contents
Add Comment
Please, Sign In to add comment