Announcement Announcement Module
Collapse
No announcement yet.
Hibernate session in custom interceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate session in custom interceptor

    Hi, my question is related to Hibernate, and I'm sorry if this is not right place for post.

    DocumentLifeCycleService is responsible for managing lifecycle of Document and automatically changes status of Document based on previous status and user action. It has method:
    Code:
    public void resolveNextState(Document document, ActionType action)
    , for managing statuses.

    In order to keep track of all changes of document status we need to log all changes in some database table (info about new status, who made changes, when and what was the action). My idea was to create interceptor (implementing MethodInterceptor) which will intercept call to resolveNextState, catch status before calling method, catch the status after calling a method, compare it, and if status has changed to persist info in log table.

    My question is: how to manage Hibernate session in this interceptor. By injecting it? Should I manually begin and end transaction in method call, because transactions are defined declaratively on service layer?

    Thanks in advance. Regards.

  • #2
    Have you thought using Hibernate interceptors ?
    http://hibernate.javabeat.net/articl...-introduction/
    http://www.hibernate.org/hib_docs/v3...e-interceptors

    Comment


    • #3
      Hi Andrei,
      thanks for the link for this article:
      http://hibernate.javabeat.net/articl...-introduction/

      I was thinking about Hibernate Interceptor but I need to store also information about user action which cause changing of document status, which is argument of service method call. In Hibernate Inteceptor I can only examin object which is persistent.

      Am I right?

      Thanks again.
      Last edited by jandrla; Oct 3rd, 2007, 04:56 PM.

      Comment

      Working...
      X