Announcement Announcement Module
No announcement yet.
VPD with Hibernate and iBatis Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • VPD with Hibernate and iBatis

    I need to access database with some sort of DB connection context settings to secure data with VPD (Virtual Private Database) based on Web login user. It requires me to set the context right after connection creation and clear the context right before release connection back to the pool. My Web application stack contains Hibernate, iBatis or combination of both.

    Originally, to avoid setting and clearing context on every single data access, I was thinking I could intercept requests with a Web Filter grabbing a connection with DataSourceUtils, setting the context on the connection once and clearing the context at the end. However, I'm not so sure if this the good way to handle it. Or I'm asking trouble here. Any thoughts would be very appreciated.

    Here's the problem.
    Hibernate keeps the same connection throughout the entire Web request (using OpenSessionInViewFilter), which is good. Howvever, when iBatis tries to access data during the same Web request with Hibernate, it uses a different connection. Is there any efficient way that I can make iBatis join the same connection? In the same other Web request cannot use the same connection. By the way, most queries are SELECT, not UPDATE or INSERT.


  • #2
    Anyone came across this one? Any advices pointing to a right direction would be really appreciated.


    • #3
      VPD and iBATIS

      Hello spnewby -- Did you find a solution yet for this issue? I came up with one, see here:

      -- erik