Is there a way to get all managed entities from an EntityManager
I'm setting up a basic test data util and want to keep track of all the data that the EntityManager handles. Rather than just having a bunch of lists for each entity is there a way to grab everything being managed by the EntityManager in one fell swoop? So instead of this: EntityManager em; List<Entity1> a; List<Entity2> b; ... List<Entityn> n; cleanup() { for(Entity1 e : a) em.remove(e); for(Entity2 f : b) em.remove(f); ... for(Entityn z : n) em.remove(z); } I want something like this; EntityManager em; cleanup() { List<Object> allEntities = em.getAllManagedEntities(); //<-this doesnt exist