-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Passing an object to an Interceptor?
PostPosted: Wed Jul 02, 2008 5:36 pm 
Beginner
Beginner

Joined: Wed Apr 23, 2008 12:07 pm
Posts: 22
Hi there.

I am trying to audit changes. I am using an Interceptor and Hibernate version 3.2. The onFlushDirty event fires fine and my insert into the table history (saving another history bean with old and new values) works too.

The only problem is I would like to know WHO makes these changes so I will have to log the user. But the user is not the same that connects to the database, because all database connects are made with one and the same user.

I am saving my user after login in the HttpSession. But how can I get this user entity in an interceptor? :(


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 8:57 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
getUserPrincipal on the HttpRequest object will tell you who logged into the web app and made the change. If this isn't the user making the database connection, which obviously it is not, you're going to have to explicitly pass this to the back end by injecting a variable into an HQL query, or writing to a log file directly.

Basically, you've got to explicitly pass this information to the back end.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.