Proper hibernate hibernate testing with H2

I am currently using below, after every test that I have in my test suite. However, this makes it very slow, because H2 needs to reload the application context after each test. Is there a faster way to clear all my objects so that I don’t have hyphenation between tests?

@org.junit.After
public void tearDown() throws Exception {
    context.close();
}
+5
source share
1 answer

Try context.clear()

EntityManager.clear: clear the persistence context, as a result of which all managed objects will be disconnected. Changes made to objects that have not been flushed to the database will not be saved.

Session.clear: Completely clear the session.

, , / , , , . SQL script . PersistenceHelper .

+7

All Articles