Hello,
I am having difficulty calling a simple PL/SQL stored procedure via JdbcTemplate that updates a row. From the attached trace log, it appears that the entire transaction lifecycle IS processed by Spring for the call. I get no exception. However, the row is not updated. It appears that Spring is not committing the transaction.
I was wondering if anyone had any thought on this.
Thanks,
Here is the relevant part of context configuration:
And, here is how my service method is setup. I have the service class annotated with @Service
And, here is the trace log:
I am having difficulty calling a simple PL/SQL stored procedure via JdbcTemplate that updates a row. From the attached trace log, it appears that the entire transaction lifecycle IS processed by Spring for the call. I get no exception. However, the row is not updated. It appears that Spring is not committing the transaction.
I was wondering if anyone had any thought on this.
Thanks,
Here is the relevant part of context configuration:
Code:
<!-- Transaction Config -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"
p:jpaDialect-ref="jpaDialect"/>
<!-- use declarative transaction management -->
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
<!-- -->
<!-- SQL Datasource config (for use by JPA and JdbcTemplate -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" scope="session">
<aop:scoped-proxy />
<property name="driverClassName" value="${db.jdbc.connection.driver.class}"/>
<property name="url" value="${db.jdbc.connection.url}" />
<property name="defaultAutoCommit"><value>false</value></property>
<property name="poolPreparedStatements"><value>true</value></property>
<property name="initialSize"><value>2</value></property>
<property name="maxActive"><value>10</value></property>
<property name="maxIdle"><value>8</value></property>
<property name="maxWait"><value>10000</value></property>
<property name="removeAbandoned"><value>true</value></property>
<property name="removeAbandonedTimeout"><value>300</value></property>
<property name="accessToUnderlyingConnectionAllowed">
<value>true</value>
</property>
</bean>
<!-- -->
<!-- Spring JdbcTemplate config -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
scope="session">
<constructor-arg ref="dataSource" />
</bean>
<!-- -->
<!-- Start JPA Config -->
<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="false" />
</bean>
<!-- JPA Entity Manager Factory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource" p:persistenceXmlLocation="classpath:persistence.xml"
p:persistenceUnitName="dis" p:jpaVendorAdapter-ref="jpaAdapter" scope="session">
<aop:scoped-proxy />
</bean>
<!-- End JPA Config -->
Code:
@Transactional
public void setCorctOcurInd(Long tran, String indicator) throws Exception {...}
Code:
14:14:25 DEBUG (AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager'
14:14:25 DEBUG (AbstractPlatformTransactionManager.java:365) Creating new transaction with name [xxxx.ProcessCorrService.setCorctOcurInd]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
14:14:25 DEBUG (SessionImpl.java:312) Opened session at timestamp: 13678748651
14:14:25 DEBUG (SessionImpl.java:312) Opened session at timestamp: 13678748651
14:14:25 TRACE (SessionImpl.java:1363) Setting flush mode to: AUTO
14:14:25 TRACE (SessionImpl.java:1380) Setting cache mode to: NORMAL
14:14:25 DEBUG (JpaTransactionManager.java:368) Opened new EntityManager [org.hibernate.ejb.EntityManagerImpl@678277bc] for JPA transaction
14:14:25 DEBUG (AbstractTransactionImpl.java:158) begin
14:14:25 DEBUG (LogicalConnectionImpl.java:295) Obtaining JDBC connection
14:14:25 DEBUG (LogicalConnectionImpl.java:301) Obtained JDBC connection
14:14:25 DEBUG (JdbcTransaction.java:69) initial autocommit status: false
14:14:25 TRACE (TransactionSynchronizationManager.java:193) Bound value [org.springframework.orm.jpa.EntityManagerHolder@26830cbb] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@9317bfb] to thread [550001695@qtp-230594925-6]
14:14:25 TRACE (TransactionSynchronizationManager.java:272) Initializing transaction synchronization
14:14:25 TRACE (TransactionAspectSupport.java:361) Getting transaction for [xxxx.ProcessCorrService.setCorctOcurInd]
14:14:25 DEBUG (SqlCall.java:154) Compiled stored procedure. Call string is [{call PKG_DC_PROCESS_CORR.set_corct_ocur_ind(?, ?)}]
14:14:25 DEBUG (RdbmsOperation.java:343) RdbmsOperation with SQL [PKG_DC_PROCESS_CORR.set_corct_ocur_ind] compiled
14:14:25 DEBUG (JdbcTemplate.java:998) Calling stored procedure [{call PKG_DC_PROCESS_CORR.set_corct_ocur_ind(?, ?)}]
14:14:25 DEBUG (DataSourceUtils.java:110) Fetching JDBC Connection from DataSource
14:14:25 DEBUG (DataSourceUtils.java:114) Registering transaction synchronization for JDBC Connection
14:14:25 TRACE (TransactionSynchronizationManager.java:193) Bound value [org.springframework.jdbc.datasource.ConnectionHolder@5decacf5] for key [org.apache.commons.dbcp.BasicDataSource@3842cbda] to thread [550001695@qtp-230594925-6]
14:14:25 TRACE (StatementCreatorUtils.java:206) Setting SQL statement parameter value: column index 1, parameter value [2697], value class [java.lang.Long], SQL type 2
14:14:25 TRACE (StatementCreatorUtils.java:206) Setting SQL statement parameter value: column index 2, parameter value [Y], value class [java.lang.String], SQL type 12
14:14:25 TRACE (TransactionSynchronizationManager.java:140) Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@5decacf5] for key [org.apache.commons.dbcp.BasicDataSource@3842cbda] bound to thread [550001695@qtp-230594925-6]
14:14:25 DEBUG (JdbcTemplate.java:1069) CallableStatement.execute() returned 'false'
14:14:25 DEBUG (JdbcTemplate.java:1070) CallableStatement.getUpdateCount() returned -1
14:14:25 TRACE (TransactionSynchronizationManager.java:140) Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@5decacf5] for key [org.apache.commons.dbcp.BasicDataSource@3842cbda] bound to thread [550001695@qtp-230594925-6]
14:14:25 TRACE (TransactionAspectSupport.java:390) Completing transaction for [xxxx.ProcessCorrService.setCorctOcurInd]
14:14:25 TRACE (AbstractPlatformTransactionManager.java:922) Triggering beforeCommit synchronization
14:14:25 TRACE (AbstractPlatformTransactionManager.java:935) Triggering beforeCompletion synchronization
14:14:25 TRACE (TransactionSynchronizationManager.java:243) Removed value [org.springframework.jdbc.datasource.ConnectionHolder@5decacf5] for key [org.apache.commons.dbcp.BasicDataSource@3842cbda] from thread [550001695@qtp-230594925-6]
14:14:25 DEBUG (DataSourceUtils.java:327) Returning JDBC Connection to DataSource
14:14:25 DEBUG (AbstractPlatformTransactionManager.java:752) Initiating transaction commit
14:14:25 DEBUG (JpaTransactionManager.java:507) Committing JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@678277bc]
14:14:25 DEBUG (AbstractTransactionImpl.java:173) committing
14:14:25 TRACE (SessionImpl.java:398) Automatically flushing session
14:14:25 TRACE (SessionImpl.java:606) before transaction completion
14:14:25 DEBUG (JdbcTransaction.java:113) committed JDBC Connection
14:14:25 TRACE (TransactionCoordinatorImpl.java:136) after transaction completion
14:14:25 TRACE (SessionImpl.java:618) after transaction completion
14:14:25 TRACE (AbstractPlatformTransactionManager.java:948) Triggering afterCommit synchronization
14:14:25 TRACE (AbstractPlatformTransactionManager.java:964) Triggering afterCompletion synchronization
14:14:25 TRACE (TransactionSynchronizationManager.java:331) Clearing transaction synchronization
14:14:25 TRACE (TransactionSynchronizationManager.java:243) Removed value [org.springframework.orm.jpa.EntityManagerHolder@26830cbb] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@9317bfb] from thread [550001695@qtp-230594925-6]
14:14:25 DEBUG (JpaTransactionManager.java:593) Closing JPA EntityManager [org.hibernate.ejb.EntityManagerImpl@678277bc] after transaction
14:14:25 DEBUG (EntityManagerFactoryUtils.java:335) Closing JPA EntityManager
14:14:25 TRACE (SessionImpl.java:337) Closing session
14:14:25 TRACE (LogicalConnectionImpl.java:193) Closing logical connection
14:14:25 TRACE (JdbcResourceRegistryImpl.java:205) Closing JDBC container [org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl@5a7e8edf]
14:14:25 DEBUG (LogicalConnectionImpl.java:314) Releasing JDBC connection
14:14:25 DEBUG (LogicalConnectionImpl.java:332) Released JDBC connection
14:14:25 TRACE (LogicalConnectionImpl.java:207) Logical connection closed