org.dspace.core.Context has too many jobs to do, with conflicting lifecycles. In particular the incorporation of a Session leads to problems interacting with Hibernate, and results in work-arounds that are complex and sometimes confusing. I believe that we need to move the management of Sessions from Context into the DAOs:
- to promote smaller, shorter-lived transactions;
- to simplify non-transactional read-only queries;
- to support multiple Sessions in long-lived bulk operations with many short-lived read/write operations driven by a longer-lived read-only result stream;
- to localize Session management decisions within the code that can best make them (with hints from upper layers).