繁体   English   中英

JPA事务中的jdbc自动提交功能

[英]jdbc auto commit features inside a JPA transaction

我有如下拖曳方法:

@org.springframework.transaction.annotation.Transactional
public boolean creditAccount(String accountId)
{
      LogUtility.logTxn(accountId);
      // Do somethings 
}

public class LogUtility
{
    javax.sql.DataSource dataSource; // this property initialized in static block of intilalizing LogUtility class

    public logTxn(String account)
    {
       java.sql.Connection conn = dataSource.getConnection();
       conn.setAutoCommit(true);
       CallableStatement cs = conn.prepareCall(/*name of a oracle package and its procedures*/);
       cStmt.execute();   
    }
}

我想了解在LogUtility.logTxn方法调用之后在creditAccount方法中发生异常的情况(在这里: // Do somethings ),然后LogUtility.logTxn方法提交或回滚? 我知道creditAccount方法在这种情况下会回滚,但是我不知道logTxn方法的行为。

您从数据源创建了另一个连接,这意味着您与数据库建立了另一个会话,因此该连接具有其事务,并且单独提交/ rollback

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM