Details
Description
We are using apache camel to poll from a database. As we want processed rows only to be updated we have disabled consumeDelete on the JPA endpoint.
During testing we found a large memory leak: all polled entities are kept in the session cache (we are using hibernate as persistence provider).
The issue seems to be in the JpaConsumer. In method poll() it calls enitityManager.joinTransaction() at the beginning and entitiyManager.flush() at the end of the method but it never calls entityManager.clear(). As camel is reusing the underlying session during each poll() this causes the first level entity cache to grow indefinitely.