I have a simple Java SE Application which uses JPA(EclipseLink). By default I have one 'default' connection pool which allows up to 32 connections.
Suppose I do something like this:
EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("myPU");
//read
EntityManager em = emFactory.createEntityManager();
TypedQuery<Entity.class> q = em.createQuery("Select e from Entity e", Entity.class);
List<Entity> entities = q.getResultList();
em.close();
//write
em = emFactory.createEntityManager();
Entity e = new Entity();
em.getTransaction().begin();
em.persist(e);
em.getTransaction().commit();
em.close();
- When are connections actually requested from the connection pool and when are they released again?
- Can one query request multiple connections from the pool?
- Would there be a difference if I set the maximum number of connections from 32 to 1?