带有aop事务配置的Spring jdbc没有提交

时间:2011-10-02 10:29:27

标签: java spring spring-aop

我在Tomcat 6中使用Spring 3.0.6和JDK 1.6。我使用Spring引用为Spring JDBC配置了声明式事务。我在日志中看到我的删除查询,但在执行后,记录不会被删除。不知道是什么原因?

Creating new transaction with name [com.accept.web.modules.personalization.UserPreferencesServiceImpl.delete]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
Acquired Connection [ProxyConnection[PooledConnection[oracle.jdbc.driver.T4CConnection@73bddb4e]]] for JDBC transaction
Bound value [org.springframework.jdbc.datasource.ConnectionHolder@3f6f1ea2] for key [org.apache.tomcat.jdbc.pool.DataSource@1123065c{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=oracle.jdbc.OracleDriver; maxActive=30; maxIdle=3; minIdle=0; initialSize=0; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=600000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=1800000; testWhileIdle=true; testOnConnect=false; password=accept; url=jdbc:oracle:thin:@bbhangale-pc:1521/bbhangale; username=accept; validationQuery=select name from usr_user where id=104; validationInterval=1200000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=true; removeAbandonedTimeout=360; logAbandoned=true; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; alternateUsernameAllowed=false; }] to thread [http-8001-1]
Initializing transaction synchronization
Getting transaction for [com.accept.web.modules.personalization.UserPreferencesServiceImpl.delete]
Executing prepared SQL update
Executing prepared SQL statement [SELECT "KEY", "VALUE" FROM config WHERE "KEY" IN (?) AND user_id = ?]
Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@3f6f1ea2] for key [org.apache.tomcat.jdbc.pool.DataSource@1123065c{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=oracle.jdbc.OracleDriver; maxActive=30; maxIdle=3; minIdle=0; initialSize=0; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=600000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=1800000; testWhileIdle=true; testOnConnect=false; password=accept; url=jdbc:oracle:thin:@bbhangale-pc:1521/bbhangale; username=accept; validationQuery=select name from usr_user where id=104; validationInterval=1200000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=true; removeAbandonedTimeout=360; logAbandoned=true; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; alternateUsernameAllowed=false; }] bound to thread [http-8001-1]
Setting SQL statement parameter value: column index 1, parameter value [FILTER_rcaGrid], value class [java.lang.String], SQL type unknown
Setting SQL statement parameter value: column index 2, parameter value [107], value class [java.lang.Integer], SQL type unknown
Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@3f6f1ea2] for key [org.apache.tomcat.jdbc.pool.DataSource@1123065c{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=oracle.jdbc.OracleDriver; maxActive=30; maxIdle=3; minIdle=0; initialSize=0; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=600000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=1800000; testWhileIdle=true; testOnConnect=false; password=accept; url=jdbc:oracle:thin:@bbhangale-pc:1521/bbhangale; username=accept; validationQuery=select name from usr_user where id=104; validationInterval=1200000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=true; removeAbandonedTimeout=360; logAbandoned=true; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; alternateUsernameAllowed=false; }] bound to thread [http-8001-1]
SQL update affected 1 rows
Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@3f6f1ea2] for key [org.apache.tomcat.jdbc.pool.DataSource@1123065c{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=oracle.jdbc.OracleDriver; maxActive=30; maxIdle=3; minIdle=0; initialSize=0; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=600000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=1800000; testWhileIdle=true; testOnConnect=false; password=accept; url=jdbc:oracle:thin:@bbhangale-pc:1521/bbhangale; username=accept; validationQuery=select name from usr_user where id=104; validationInterval=1200000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=true; removeAbandonedTimeout=360; logAbandoned=true; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; alternateUsernameAllowed=false; }] bound to thread [http-8001-1]
Completing transaction for [com.accept.web.modules.personalization.UserPreferencesServiceImpl.delete]
Triggering beforeCommit synchronization
Triggering beforeCompletion synchronization
Initiating transaction commit
Committing JDBC transaction on Connection [ProxyConnection[PooledConnection[oracle.jdbc.driver.T4CConnection@73bddb4e]]]
Triggering afterCommit synchronization
Triggering afterCompletion synchronization
Clearing transaction synchronization
Removed value [org.springframework.jdbc.datasource.ConnectionHolder@3f6f1ea2] for key [org.apache.tomcat.jdbc.pool.DataSource@1123065c{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=oracle.jdbc.OracleDriver; maxActive=30; maxIdle=3; minIdle=0; initialSize=0; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=600000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=1800000; testWhileIdle=true; testOnConnect=false; password=accept; url=jdbc:oracle:thin:@bbhangale-pc:1521/bbhangale; username=accept; validationQuery=select name from usr_user where id=104; validationInterval=1200000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=true; removeAbandonedTimeout=360; logAbandoned=true; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; alternateUsernameAllowed=false; }] from thread [http-8001-1]
Releasing JDBC Connection [ProxyConnection[PooledConnection[oracle.jdbc.driver.T4CConnection@73bddb4e]]] after transaction
Returning JDBC Connection to DataSource

1 个答案:

答案 0 :(得分:0)

现在一切正常。我忘了将查询更改为删除查询。正如您所指出的那样,您无法在日志中看到任何删除查询。