Hi folks this is follow up from a previous question (which I was able to answer). This is one is slightly different (in this case we are in fact creating new entities) but essentially the same problem, the JPA EntityManager (session) is holding on to entities longer then it needs to.
The psuedo code below more or less does this:
(fetch a bunch of entites give an id list, clone them, perist the cloned records back into the dabase).
Code:
while(!done)
{
List<Entity> entities = findByIds(bigIdList);
for (Entity e : entities)
{
tmp = new Entity(e);
tmp.setId(null);
entityManager.persist(tmp);
}
entityManager.flush(); // send the 'transactional info off to the database
entityManager.clear(); // flush all entities form the session.
}
transaction.commit();
From what I can tell based on visualVM, my entity cont contnue to climb, regardless of the flush/clear operations.
Any thoughts as to what/why the session is still holding the references?
note:
Looking closer at Memory heap, shows, references are being held from something in hibernate/jpa:
EntityIdentityInsertAction <- ActionQueue <-SessionImpl
so indeed the session is not flushing the insert sql over to the database....
Thanx
Dan