【问题标题】:Consuming saved object in aspect在方面消费保存的对象
【发布时间】:2014-12-23 09:54:17
【问题描述】:

我有一个存储库类,其方法如下:

@Transactional
@Modifying(clearAutomatically = true)
@Query("update Form f set f.xmlWithData =:xmlWithData where f.id =:id")
void save(@Param("xmlWithData") String xmlWithData, @Param("id") longid);

这个方法之后的建议如下:

@After("execution(* tr.com.blabla.FormRepository.save(*,*)) && args(xmlWithData,id)")
   public void generateFormData(String xmlWithData, long id) throws Exception {
}

我的问题是:

是否可以在我的建议方法中使用 Form f 对象,如下所示:

@After("execution(* tr.com.blabla.FormRepository.save(*,*)) && args(xmlWithData,id)")
public void generateFormData(String xmlWithData, long id) throws Exception{
    if(f.getSomething().equals("blabla") {
        this.doSomething();
    }
}

提前谢谢...

【问题讨论】:

  • 请对代码块使用缩进而不是三个反引号。有关于格式化的在线帮助,顺便说一句。 :-)

标签: spring spring-data-jpa aspectj


【解决方案1】:

不。我不这么认为,但是如果您将 Form 对象作为参数传递给 save 方法,您就可以做到。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-23
    • 1970-01-01
    相关资源
    最近更新 更多