Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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();
- }
- 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();
- }
- }
- deleting db contents
Add Comment
Please, Sign In to add comment