How do I delete all JPA entities?
问题 In my testing code I need to have a blank/empty database at each method. Is there code that would achieve that, to call in the @Before of the test? 回答1: Actually you always can use JPQL, em .createQuery("DELETE FROM MyEntity m") .executeUpdate() ; But note, there is no grants that entity cache would be cleaned also. But for unit-test purposes it is look like good solution. 回答2: In my testing code I need to have a blank/empty database at each method. I would run the test methods insider a