• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with auditing in Hibernate - how to get the userid from HttpSession???

 
newbie awo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I'm a newbie to Hibernate, so I'm hoping this is an easy problem.

Basically, I have a web application that uses Tapestry, Spring and Hibernate (v3.1).

I have an event interceptor that gets called on every save-update event for audit logging. I am able to log everything except the user_id, which is stored as an attribute in the httpsession. The presentation layer takes care of storing the user in the HttpSession, of course.

So my question basically is,

is there any way to access the HttpSession from within my implementation of the DefaultSaveUpdateEventListener (which otherwise works like a champ)?

Thanks in advance for your help!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"newbie awo"

Welcome to JavaRanch!

Can you please update your display name so it complies with our Naming Policy. You can do this here.

Thanks!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i have got your question right, you have implemented a event interceptor which logs some messages. You want the userid to be a part of the message. If that's the case, have a look at:

NDC/MDC section atLog4j article
Log4j MDC article

You will find a code sample(MDCUserServletFilter.java) at:
Code sample

I am assuming that you are using log4j.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic