Jan 30th, 2007, 04:26 PM
Spring + JPA + Hibernate - userid - need to pass to database
we are currently using combination of Spring + JPA + Hibernate + Oracle. We use application managed security and all user sessions share the same database account. I need to pass application userid to database (for audit, security etc).
Is there any way to do it in generic way on Spring, JPA or Hibernate level? Right now we code out DAOs to extend JpaDaoSupport. Simply we need to pass it (call stored procedure that would set up environment variable or so) every time new EntityManager is created. Did anyone do anything like that in the past? Thanks
Jan 30th, 2007, 04:30 PM
Please ignore this thread. Posted by mistake. My apologies.
Jan 31st, 2007, 07:25 AM
Edit: now I see the reason why you wanted to ignore this thread, it was a double post. all apologies.
I know you asked people to ignore this, but I have the same kind of question.
The "best solution" that tech lead wants is for the Java layer to somehow pass the userid. The trick is we don't want to append them in the the sql (or hql actually because we're using hibernate).
the thinking is that a trigger will run on insert/update that will grab the userId from the Oracle context (I'm not even sure if that's the right word). So basically, Java sets the userId in the context and then does the insert/update statement (well hibernate executes the statement). Then the trigger runs, grabs the userId and inserts into a log. Has anyone done logging this way? Is it possible?
Your help is greatly appreciated, Googling phrases has seemed to not work out all that well for me with this task.