-->
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.  [ 1 post ] 
Author Message
 Post subject: Need ideas on user name logging with managed connections
PostPosted: Thu Sep 29, 2005 7:02 pm 
Beginner
Beginner

Joined: Thu Dec 09, 2004 7:04 pm
Posts: 26
Location: Denver, CO
Hibernate version: 3

I've been using Session.currentSession() to get the current managed
transaction (I actually use a helper class that substitutes openSession()
for unit tests).

I'm looking at performing some audit capabilities using events and/or interceptors. I've read most of the forum topics on auditing
and all of them seem to use interceptors that are added at session creation time.

They have something like:
Code:
String user = getUserSomehow();
Interceptor i = new MyInterceptor(user);
Session session = factory.openSession(i);


What I'm looking for is something like:
Code:
String user = getUserSomehow();
Interceptor i = new MyInterceptor(user);
Session session = factory.currentSession(i);


This would use the interceptor if it needed to create a new session.

The only other way I can see to do this is to put a lot of work into the interceptor. I would have to do the following:
    Assign the cuid to the current JTA transaction
    Specify the interceptor in the configuration
    Have the interceptor grab the user name from the JTA transaction


That seems like a lot of work. Does anyone have a better idea of logging the user name when using container managed sessions?

John


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

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.