Skip to content

Clean up database between tests

Patrick Huang edited this page Oct 1, 2013 · 1 revision
EntityCleaner.deleteAll(entityManager, 
    Arrays.asList(LineItem.class, Category.class, Person.class));

Not only it will delete the entity represented table but also delete any @ManyToMany or @ElementCollection derived tables. But you will have to work out the order of the deletion so that no referential constraint is violated.

Clone this wiki locally