java - Spring 事务管理 - 在哪里放置注释?

标签 java spring transactions annotations

如果我有一个事务管理类,其中有两个方法,例如

void OuterMethod(Data somedata)
{
   this.InnerMethod(somedata)
}

@Transactional("mymanager")
void InnerMethod(Data somedata)
{
    //writes some things 
}

这有效吗?由于某种原因,我无法将其写入数据库,尽管它没有给我任何错误。

最佳答案

Spring does not use bytecode instrumentation to implement AOP. So it is predictable that if a method of a proxied object calls an other method in the same object, the aspect will not be applied on the method call. Spring allows however to apply the aspect on this method call by setting exposeProxy to True and using AopContext.currentProxy().

该信息可能有点过时,但据我所知,它仍然准确(但不确定“exposeProxy”标志)

参见http://forum.springsource.org/showthread.php?t=9926

关于java - Spring 事务管理 - 在哪里放置注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3350659/

相关文章:

SELECT 中的 Mysql 死锁.. 如果不存在 INSERT

java - Hibernate 事务不工作

java - 日历未给出正确的日期

Java 小程序无法加载

java - org.apache.catalina.connector.RequestFacade 无法转换为 org.springframework.web.multipart.MultipartHttpServletRequest

java - Spring Boot 模糊映射。无法映射方法

sql-server - 事务中的sql进度记录

java - 在 Apache Spark 中加入、聚合然后选择特定列

java - Hadoop。如何从 Mapper 获得工作

java - Vaadin、Jetty、Spring Data、Maven - 异常