Announcement Announcement Module
Collapse
No announcement yet.
Is EntityInterceptors Are ThreadSafe? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is EntityInterceptors Are ThreadSafe?

    Hi all,

    I'm developing Audit Trail. So on any Create,Update,Delete operation on any table will call EntityInterceptor.

    Now if anytime,
    1) Two persons edit diff row in same table or,
    2) Two persons edit diff row in diff table or,
    3) Two person edit same row

    will there be any issue in any of above 3 case? (regarding thread Safe)

    in any scenario i may get improper value for editing operation

  • #2
    Originally posted by rohan123 View Post
    Hi all,

    I'm developing Audit Trail. So on any Create,Update,Delete operation on any table will call EntityInterceptor.

    Now if anytime,
    1) Two persons edit diff row in same table or,
    2) Two persons edit diff row in diff table or,
    3) Two person edit same row

    will there be any issue in any of above 3 case? (regarding thread Safe)

    in any scenario i may get improper value for editing operation
    entity interceptor is just an implementation of the org.hibernate.Interceptor interface so if you don't do anything crazy in your implementation (like create stateful data or something like that) you'll be safe.

    so in your scenarios above, all of those actions can be audited with the proper implementation on org.hibernate.Interceptor interface....

    Comment


    • #3
      Originally posted by bdangubic View Post
      so if you don't do anything crazy in your implementation (like create stateful data or something like that) you'll be safe.
      All this value has to be inserted in onFlushDirty. So can this create prob?

      i'm doing Audit trial so once a field's value say modify i need to add it in table by previous value ,new value, who did,when etc.

      Comment


      • #4
        Originally posted by rohan123 View Post
        All this value has to be inserted in onFlushDirty. So can this create prob?

        i'm doing Audit trial so once a field's value say modify i need to add it in table by previous value ,new value, who did,when etc.
        yea, just fire away, just log your audits from the interceptor

        Comment


        • #5
          Originally posted by bdangubic View Post
          yea, just fire away, just log your audits from the interceptor
          ok thank you for ur help.

          One more thing i want to ask that onFlushDirty method is called when transaction is committed?

          i only want when transaction committed then i want to add in audit table.

          Comment

          Working...
          X