Spring data jpa 添加过滤器/拦截器 [英] Spring data jpa add filter/interceptor

查看:28
本文介绍了Spring data jpa 添加过滤器/拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前使用过 hibernate,并成功添加了一个过滤器,可以拦截保存和实现某个接口的实体会记录一些内容.

I have used hibernate before, and have successfully added a filter that would intercept saves and entities who implemented a certain interface would have something logged.

是否可以在新的 Spring Data 中做类似的事情,我刚刚开始使用它.

Is it possible to do something similar in the new Spring Data, I have just started out using it.

推荐答案

是的,您始终可以使用 spring 数据添加过滤器/拦截器

Yes you can always add filters/interceptors with spring data

以下是一个例子:

<bean id="customizableTraceInterceptor" class="
  org.springframework.aop.interceptor.CustomizableTraceInterceptor">
  <property name="enterMessage" value="Entering $[methodName]($[arguments])"/>
  <property name="exitMessage" value="Leaving $[methodName](): $[returnValue]"/>
</bean>

<aop:config>
  <aop:advisor advice-ref="customizableTraceInterceptor"
    pointcut="execution(public * org.springframework.data.jpa.repository.JpaRepository+.*(..))"/>
</aop:config>

参考:http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/

这篇关于Spring data jpa 添加过滤器/拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆