如何在Websphere AS 7.0上查找在事务中执行的sql语句?

时间:2012-02-06 16:40:38

标签: sql logging transactions jta websphere-7

我有一个Websphere Application Server 7.0.0.9,正在运行的应用程序使用springframework 2.0.9hibernate 3.3.0(或3.4.0,或者两者兼而有之,我不确定)。 TransactionManager是org.springframework.transaction.jta.WebSphereUowTransactionManager

我有一个注释为@org.springframework.transaction.annotation.Transactional的方法。此方法调用另一个也注释为@org.springframework.transaction.annotation.Transactional的方法:

@Transactional
public void myMethod() {
    doSomeUpdates();
    nestedMethod();
}
@Transactional
public void nestedMethod() {
    doSomeMoreUpdates();
}

方法" myMethod"应该是atomary。有时来自" doSomeUpdates"的更新时会出现错误。回滚,但更新来自" doSomeMoreUpdates"是的。

默认传播设置为Propagation.REQUIRED。我尝试将代码更改为:

@Transactional
public void myMethod() {
    doSomeUpdates();
    nestedMethod();
}
@Transactional(propagation = Propagation.MANDATORY)
public void nestedMethod() {
    doSomeMoreUpdates();
}

我尝试查看日志以查找此更改是否已解决了我的错误,但无法让我的日志文件陷入泥潭。我通过org.hibernate.jdbc.util.SQLStatementLogger类记录sql语句,并使用以下设置将事务琐事转储到websphere的trace.log文件中:

com.ibm.wsspi.uow.*=finest: com.ibm.ws.uow.*=finest:
com.ibm.ws.jtaextensions.*=finest: org.hibernate.transaction.*=finest:
org.springframework.transaction.*=finest: com.ibm.ws.Transaction.*=finest:
com.ibm.ws.LocalTransaction.*=finest: com.ibm.ws.tx.*=finest:
oracle.jdbc.*=finest:

这会产生的无用数据,但是SQL语句报告只会转储sql语句,它似乎与websphere事务没有任何关系。如何查看每个事务中websphere真正执行的sql语句?

1 个答案:

答案 0 :(得分:0)

上周我们遇到了这个问题。看起来在Spring中已经更改了专门的插件类WebSphereUowTransactionManager以适应Websphere 7.x

我们在针对WebSphere 6.1安装使用Spring框架版本3.0.5。但是,当我们迁移到WebSphere 7.1时,我们遇到了与上面提到的问题类似的问题。在我们将Spring框架升级到版本3.1.1之前,我们疯了一会儿试图找出问题。现在一切都顺利进行了。

祝你好运。