Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The DSpace Context object has methods (like uncacheEntity() and reloadEntity()) which can manage objects cached within this Hibernate Session (via HibernateDBConnection).

...

  • Hibernate sessions are not thread-safe
    • Therefore, any new DSpace code must ensure it is not attempting to share objects or Sessions between threads. Instead, pass around UUIDs, so the new thread can load the referenced object in a new Session.
  • The more objects you load during the lifetime of a Session, the less efficient each query will be
    • So, be sure to use Context.commit() or Context.uncacheEntity() when you are done with an object
    • (recommendation: offer very specific/limited guidance on when to call uncacheEntity())
  • Because Hibernate has built-in Session caching, it is not recommended to cache objects elsewhere in your code.  If you must perform other caching, store UUIDs instead
    • Caching objects elsewhere is likely to result in a LazyInitializationException if the object (cached elsewhere) outlives its Session. See "Common Hibernate Error Messages" below.

...