This guide JCR Wiki proposes the use of a new session for each request. My task is to create a tree of jackrabbit files. So going by this guide to get properties/ nodes of each item, I would need to create new session and close it later? This way I would create a lot of sessions every time, which looks strange.
But if I use one session for all time for JCR I have problem with MemoryHeapException in JCR side and not right saved nodes sometimes.
Are there any norms towards an approach between using one session and creating a session every time? Or am I misreading the guide?
I’m more familiar with ModeShape than Jackrabbit, but in general I think it’s best practice to create a new session for each request, use that session to process the request, and then close the session.
Generally, sessions are pretty lightweight and inexpensive to create. But there are some reasons why creating separate sessions is better (or at least easier):
There may be other reasons I’m not thinking of, but regardless I hope this helps.