Search code examples
javahibernategwthibernate-envers

Hiberate Envers and threads


I want to know, is it possibile to force Hibernate to call my custom RevisionListener in the same thread as the user session thread? (GWT) I need such behaviour to store in revisions name of user, who is making the changes.


Solution

  • The hibernate and envers engine run on the thread which boots up the framework and there is no way to delegate the execution of the listeners to other threads.

    The information your listener needs should be passed or provided at invocation time and your listener could use a ThreadLocal to lookup the value and use it much like how spring security based applications get this information in the revision listeners via SpringSecurityContextHolder.