Announcement Announcement Module
No announcement yet.
Running a procedure before retrieving data..Preinterceptors? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running a procedure before retrieving data..Preinterceptors?

    I'm using Spring with Hibernate in my project. Because of secrecy reasons we need to run a procedure before retrieving objects from the database. The procedure sets the user privileges in the db, so that when the call to the db is done, it retrieves the appropiate data for that user. It is not a question of changing user in every call, just a question of running a procedure before every call.

    In order to call this procedure (before my HibernateTemplate executes any method) i'm trying to use Preinterceptors, which i haven't used yet and i'm not sure if i'm using correctly or even if they're the right solution.

    Can anyone give me advice on this matter? if the interceptors are the right option, how can i call the method that calls the procedure?

    <bean id="explorerSearchService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager"/>
    <property name="target">
    <ref local="explorerSearchServiceTarget"/>
    <property name="transactionAttributes">
    <prop key="get*">PROPAGATION_REQUIRED, readOnly</prop>
    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
    <property name="preInterceptors">
    <ref bean="authorise"/>

    <bean id="authorise" class="com.csfb.fao.clr.backend.dao.hibernate.Auth orizationInterceptor">
    <property name="dataSource">
    <ref bean="dataSource"/>

    My class AuthorizationInterceptor implements Interceptor and contains a method called setClientIdentifier() that it's supposed to run the procedure. Everything compiles, but the method is never called. what am i doing wrong?