protected void performCleanUp(SessionFactory sf) { log("starting clean up phase"); FullTextSession s = Search.getFullTextSession(sf.openSession()); try { Transaction tx = s.beginTransaction(); s.createSQLQuery("delete from book_author where book_id < :id") .setParameter("id", initialOffset) .executeUpdate(); s.createSQLQuery("delete from book where id < :id") .setParameter("id", initialOffset) .executeUpdate(); s.createSQLQuery("delete from author where id < :id") .setParameter("id", initialOffset) .executeUpdate(); s.purgeAll(Book.class); s.flush(); s.flushToIndexes(); tx.commit(); } finally { s.close(); } }