Hello,
we can't understand why the performance of queries is not the best and the execution requires so much memory.
In the implementation of our UnitTests we have used "DELETE FROM Object" to delete the database. That did not work because we often get an "out of memory" exception.
What's all done in the execution of queries? Why is so much memory is required, although from the application point of view, no object is loaded.
An Example: [To get the error they please limit the memory to 512mb (VM-argument: -Xmx512m)]
import java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.FlushModeType; import javax.persistence.OneToMany; import javax.persistence.Persistence; import javax.persistence.Query; public class MemoryUsageOfQuerys { static int steps = 500000; public static void main(String[] args) { EntityManagerFactory emf = Persistence .createEntityManagerFactory("objectdb:$objectdb/db/test.tmp;drop"); EntityManager em; for (int i = 0; i < 100; i++) { em = emf.createEntityManager(); em.setFlushMode(FlushModeType.AUTO); em.getTransaction().begin(); MyEntity myEntity = new MyEntity(); myEntity = em.merge(myEntity); for (int m = 0; m < steps; m++) { MyEntityElement myEntityElement = new MyEntityElement(); myEntity.getList().add(myEntityElement); } em.getTransaction().commit(); em.close(); System.out.print("."); } em = emf.createEntityManager(); em.setFlushMode(FlushModeType.AUTO); em.getTransaction().begin(); Query q = em.createQuery("DELETE FROM Object"); q.executeUpdate(); // <- OUT OF MEMORY with VM-argument: -Xmx512m em.getTransaction().commit(); em.close(); emf.close(); } @Entity public static class MyEntity { @OneToMany(cascade = CascadeType.ALL) private List<MyEntityElement> list = new ArrayList<>(); public List<MyEntityElement> getList() { return list; } } @Entity public static class MyEntityElement { @ElementCollection private float value = 0; } }