Announcement Announcement Module
Collapse
No announcement yet.
Transaction Management Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction Management

    Hi

    Could anyone help me with the following. I've just started using Spring transaction management but haven't managd to get it to work. I've setup my project to use TransactionProxyFactoryBean as described on P250 of J2EE Development Without EJB. I've then simulated a failed transaction by duplicationg the primary key of a table insert. I'd expect the transaction to rollback, and not commitany of the other 2 table inserts.

    My applicationContext and Debug stack trace is as below:



    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "/META-INF/spring-beans.dtd">
    <beans>
      <!--=============== BUSINESS OBJECT DEFINITIONS ======================= -->
    <!--===FILING CABINET AS POJO ==-->
    <!--
    <bean id="filingCabinet" class="com.cyc.model.bo.filingcabinet.impl.FilingCabinetImpl">
      <property name="filingCabinetDao"><ref bean="filingCabinetDao"/></property>
    </bean>
    -->
    
    <bean id="filingCabinetTarget" class="com.cyc.model.bo.filingcabinet.impl.FilingCabinetImpl">
      <property name="filingCabinetDao"><ref bean="filingCabinetDao"/></property>
    </bean>
    
    <bean id="filingCabinet" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager"><ref bean="myTransactionManager"/></property>
      <property name="target"><ref bean="filingCabinetTarget"/></property>
      <property name="transactionAttributes">
        <props>
          <prop key="createOrUpdate">PROPAGATION_REQUIRED</prop>
        </props>
      </property>
    </bean>
    
      <!--=== APPLICATION AS POJO ==-->
      <bean id="application" class="com.cyc.model.bo.impl.ApplicationImpl">
        <property name="applicationDao"><ref bean="applicationDao"/></property>
      </bean>
      <!--=== DOCUMENT AS POJO ==-->  
    <bean id="document" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager"><ref bean="myTransactionManager"/></property>
      <property name="target"><ref bean="documentTarget"/></property>
      <property name="transactionAttributes">
        <props>
          <prop key="create">PROPAGATION_REQUIRED</prop>
        </props>
      </property>
    </bean>
      
      
      <bean id="documentTarget" class="com.cyc.model.bo.impl.DocumentImpl">
        <property name="documentDao"><ref bean="documentDao"/></property>
        <property name="documentImageDao"><ref bean="documentImageDao"/></property>  
        <property name="auditBo"><ref bean="audit"/></property>        
        <property name="referenceBo"><ref bean="reference"/></property>           
      </bean>
      <!--=== REFERENCE AS POJO ==-->  
      <bean id="reference" class="com.cyc.model.bo.reference.impl.ReferenceImpl">
        <property name="referenceDao"><ref bean="referenceDao"/></property>
      </bean>
      <!--=== SUBAPPLICATION AS POJO ==-->  
      <bean id="subApplication" class="com.cyc.model.bo.impl.SubApplicationImpl">
        <property name="subApplicationDao"><ref bean="subApplicationDao"/></property>
        <property name="documentTypeDao"><ref bean="documentTypeDao"/></property>    
      </bean>
      <!--=== USERS AS POJO ==-->  
      <bean id="users" class="com.cyc.model.bo.users.impl.UsersImpl">
        <!-- set to ldapDao for LDAP authentication -->
        <!-- set to procDao for Stored Procedure authentication -->    
        <property name="authenticateDao"><ref bean="procDao"/></property>
    <!--    <property name="usersDao"><ref bean="usersDao"/></property>-->
    <!--    <property name="groupsDao"><ref bean="groupsDao"/></property>    -->
        <property name="encryption"><ref bean="md5Encryption"/></property>    
        <property name="userNameUpperCase"><value>true</value></property>        
      </bean>
    <!-- Audit as POJO -->
    <bean id="audit" class="com.cyc.model.bo.audit.impl.AuditImpl">
      <property name="documentAuditDao"><ref bean="documentAuditDao"/></property>
      <property name="documentImageAuditDao"><ref bean="documentImageAuditDao"/></property>  
    </bean>
      
    <!--========================= AUTHENTICATION ================================-->
      <!-- LDAP Authenticator -->
      <bean id="ldapDao" class="com.cyc.model.dao.authenticate.ldap.AuthenticateDAOLdap">
        <property name="initialContextFactory"><value>com.sun.jndi.ldap.LdapCtxFactory</value></property>
        <property name="providerUrl"><value>ldap&#58;//cordelia&#58;3060</value></property>  
        <property name="usersPath"><value>dc=west-midlands,dc=police,dc=uk</value></property>    
      </bean> 
      <!-- Stored Procedure Authenticator -->
      <bean id="procDao" class="com.cyc.model.dao.authenticate.proc.AuthenticateDAOProc">
        <property name="dataSource"><ref local="dataSource"/></property>  
        <property name="procName"><value>authenticate</value></property>
      </bean>
    <!--
    <bean id="authenticateDao" class="com.cyc.model.dao.authenticate.ldap.AuthenticateDAOLdap">
      <property name="initialContextFactory"><value>com.sun.jndi.ldap.LdapCtxFactory</value></property>
      <property name="providerUrl"><value>ldap&#58;//cordelia&#58;3060</value></property>  
      <property name="usersPath"><value>dc=west-midlands,dc=police,dc=uk</value></property>    
    </bean>
    -->
    <!--========================= ENCRYPTION ================================-->
      <!-- MD5 Encryption -->
      <bean id="md5Encryption" class="com.cyc.gen.encryption.MD5Encryption">
      </bean>
    
    
    
    <!-- ================= JDBC DATA ACCESS OBJECT DEFINITIONS ================= -->      
    <!-- FilingCabinet DAO -->
     <bean id="filingCabinetDao" class="com.cyc.model.dao.filingcabinet.jdbc.FilingCabinetDAOJdbc">
      <property name="dataSource"><ref local="dataSource"/></property>
      <property name="databaseSupport"><ref local="dbSupport"/></property>  
      </bean>
      <!-- Application DAO -->
      <bean id="applicationDao" class="com.cyc.model.dao.application.jdbc.ApplicationDAOJdbc">
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
      <!-- SubApplication DAO -->
      <bean id="subApplicationDao" class="com.cyc.model.dao.subapplication.jdbc.SubApplicationDAOJdbc">
        <property name="refComponentDao"><ref bean="refComponentDao"/></property>
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
      <!-- Reference DAO -->
      <bean id="referenceDao" class="com.cyc.model.dao.reference.jdbc.ReferenceDAOJdbc">
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
      <!-- Document DAO -->
      <bean id="documentDao" class="com.cyc.model.dao.document.jdbc.DocumentDAOJdbc">
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
      <!-- DocumentImage DAO -->
      <bean id="documentImageDao" class="com.cyc.model.dao.documentimage.jdbc.DocumentImageDAOJdbc">
        <property name="dataSource"><ref local="dataSource"/></property>
        <property name="lobHandler"><ref local="oracleLobHandler"/></property>    
      </bean>
      <!-- RefComponent DAO -->
      <bean id="refComponentDao" class="com.cyc.model.dao.refcomponent.jdbc.RefComponentDAOJdbc">
        <property name="dropDownValueDao"><ref bean="dropDownValueDao"/></property>
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
      <!-- DropDownValue DAO -->
      <bean id="dropDownValueDao" class="com.cyc.model.dao.dropdownvalue.jdbc.DropDownValueDAOJdbc">
        <property name="dataSource"><ref local="dataSource"/></property>
      </bean>
    <!-- DocumentAudit DAO -->
    <bean id="documentAuditDao" class="com.cyc.model.dao.documentaudit.jdbc.DocumentAuditDAOJdbc">
      <property name="dataSource"><ref local="dataSource"/></property>
    </bean>
    <!-- DocumentImageAudit DAO -->
    <bean id="documentImageAuditDao" class="com.cyc.model.dao.documentimageaudit.jdbc.DocumentImageAuditDAOJdbc">
      <property name="dataSource"><ref local="dataSource"/></property>
    </bean>
    <!-- DocumentType DAO -->
    <bean id="documentTypeDao" class="com.cyc.model.dao.documenttype.jdbc.DocumentTypeDAOJdbc">
      <property name="dataSource"><ref local="dataSource"/></property>
    </bean>
    
    <!-- ============================== LOB HANDLERS =========================== -->      
     	<!-- LobHandler for well-behaved JDBC drivers -->
    	<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"
    			lazy-init="true"/>
     	<!-- LobHandler for Oracle -->
    	<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"
    			lazy-init="true"/>
    
    
    <!-- ================= DATASOURCE DEFINITIONS ========================= -->      
    	<!-- Local DataSource that works in any environment -->
    
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
    		<property name="url"><value>jdbc&#58;oracle&#58;thin&#58;@localhost&#58;1521&#58;cyclops</value></property>
    		<property name="username"><value>crimes</value></property>
    		<property name="password"><value>crimes</value></property>
    	</bean>
    
    <!-- ================= DATABASE SPECIFIC DEFINITIONS======================= -->      
    	<bean id="dbSupport" class="com.cyc.gen.db.support.jdbc.oracle.OracleDatabaseSupport">
        <property name="dataSource"><ref local="dataSource"/></property>  
    	</bean>
    
    
    
    	<!-- JNDI DataSource for J2EE environments -->
    <!--
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    	  	<property name="jndiName"><value>jdbc/imagepDS</value></property>
    	</bean>
    -->
    
      <bean id="myTransactionManager" 
        class="org.springframework.transaction.jta.JtaTransactionManager">
      </bean>
    
    
    </beans>

    2005-03-02 15:24:19,824 DEBUG org.springframework.transaction.interceptor.Transa ctionInterceptor - Getting transaction for method 'create' in class [com.cyc.model.bo.Document]

    2005-03-02 15:24:19,824 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Using transaction object [org.springframework.transaction.jta.JtaTransaction Object@133]

    2005-03-02 15:24:19,824 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Creating new transaction

    2005-03-02 15:24:19,824 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Beginning JTA transaction

    2005-03-02 15:24:19,824 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Initializing transaction synchronization

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.support.SQLErrorCodesFact ory - Looking up default SQLErrorCodes for DataSource [org.springframework.jdbc.datasource.DriverManagerD ataSource@95]

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.support.SQLErrorCodesFact ory - Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerD ataSource@95]: name is 'Oracle'

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.support.SQLErrorCodesFact ory - SQL error codes for 'Oracle' found

    2005-03-02 15:24:21,496 DEBUG com.cyc.model.dao.reference.jdbc.ReferenceQueryByS ubAppRef - RdbmsOperation with SQL [select * from reference where ref1 = ? and ref2 = ? and ref3 = ? and ref4 = ? and reference.application_idstr=? and reference.subapplication_no=?] compiled

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.core.JdbcTemplate - Executing SQL query [select * from reference where ref1 = ? and ref2 = ? and ref3 = ? and ref4 = ? and reference.application_idstr=? and reference.subapplication_no=?]

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Opening JDBC connection

    2005-03-02 15:24:21,496 DEBUG org.springframework.jdbc.datasource.DriverManagerD ataSource - Creating new JDBC connection to [jdbc:oracle:thin:@localhost:1521:cyclops]

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Registering transaction synchronization for JDBC connection

    2005-03-02 15:24:21,512 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Bound value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=1, parameter value='20', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=2, parameter value='D1', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=3, parameter value='2', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=4, parameter value='04', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=5, parameter value='CRIME', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,512 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=6, parameter value='1', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,512 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.JdbcTemplate - Executing SQL update [insert into document(REFERENCE_ID,DOCTYPE,FILENAME,CLASSIFICAT ION,SECURITYLEVEL,FILETEXT,MISCTEXT,CHAPTER,CURR_D OCUMENTIMAGE_ID,ORIGINALFILENAME,CHECKEDOUTBY,CHEC KEDOUTAT,CHECKEDOUTWHEN,CHECKEDOUTTO,FREETEXTREQD, NUMDIARY,NUMVERSIONS,OCRREQD,OCRD,DELETED) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)]

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=1, parameter value='1', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=2, parameter value='SUSP', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=3, parameter value='applet overview.doc', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=4, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=5, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=6, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=7, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=8, parameter value='null', valueClass=null, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=9, parameter value='1', valueClass=java.lang.Long, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=10, parameter value='applet overview.doc', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=11, parameter value='ANDY', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=12, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=13, parameter value='null', valueClass=null, sqlType=93

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=14, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=15, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=16, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=17, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=18, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=19, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=20, parameter value='0', valueClass=java.math.BigDecimal, sqlType=2

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.jdbc.core.JdbcTemplate - SQL update affected 1 rows

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,528 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,590 DEBUG org.springframework.jdbc.support.lob.OracleLobHand ler - Created new Oracle LOB

    2005-03-02 15:24:21,590 DEBUG org.springframework.jdbc.support.lob.OracleLobHand ler - Set binary stream for BLOB with length 328192

    2005-03-02 15:24:21,746 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.JdbcTemplate - Executing SQL update [insert into documentimageaudit(USERNAME,COMPUTER,AUDITDATETIME ,AUDITEVENT_ID,DOCUMENTIMAGE_ID,AUDITSTR) values(?,?,?,?,?,?)]

    2005-03-02 15:24:21,746 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=1, parameter value='ANDY', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=2, parameter value='null', valueClass=null, sqlType=12

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=3, parameter value='2005-03-02 15:24:21.746', valueClass=java.sql.Timestamp, sqlType=93

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=4, parameter value='1000001', valueClass=java.lang.Long, sqlType=2

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=5, parameter value='1', valueClass=java.lang.Long, sqlType=2

    2005-03-02 15:24:21,746 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value; columnIndex=6, parameter value='View Document', valueClass=java.lang.String, sqlType=12

    2005-03-02 15:24:21,746 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,793 DEBUG org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator - Translating SQLException with SQLState '23000' and errorCode '1' and message [ORA-00001: unique constraint (CRIMES.PK_DOCUMENTIMAGEAUDIT) violated
    ]; SQL was [insert into documentimageaudit(USERNAME,COMPUTER,AUDITDATETIME ,AUDITEVENT_ID,DOCUMENTIMAGE_ID,AUDITSTR) values(?,?,?,?,?,?)] for task [executing PreparedStatementCallback [PreparedStatementCreatorFactory.PreparedStatementC reatorImpl: sql=[insert into documentimageaudit(USERNAME,COMPUTER,AUDITDATETIME ,AUDITEVENT_ID,DOCUMENTIMAGE_ID,AUDITSTR) values(?,?,?,?,?,?)]: params=[ANDY,null,2005-03-02 15:24:21.746,1000001,1,View Document]]]

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Retrieved value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] bound to thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute - Applying rules to determine whether transaction should rollback on org.springframework.dao.DataIntegrityViolationExce ption: executing PreparedStatementCallback [PreparedStatementCreatorFactory.PreparedStatementC reatorImpl: sql=[insert into documentimageaudit(USERNAME,COMPUTER,AUDITDATETIME ,AUDITEVENT_ID,DOCUMENTIMAGE_ID,AUDITSTR) values(?,?,?,?,?,?)]: params=[ANDY,null,2005-03-02 15:24:21.746,1000001,1,View Document]]: ORA-00001: unique constraint (CRIMES.PK_DOCUMENTIMAGEAUDIT) violated
    ; nested exception is java.sql.SQLException: ORA-00001: unique constraint (CRIMES.PK_DOCUMENTIMAGEAUDIT) violated


    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute - Winning rollback rule is: null

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute - No relevant rollback rule found: applying superclass default

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.Transa ctionInterceptor - Invoking rollback for transaction on method 'create' in class [com.cyc.model.bo.Document] due to throwable [org.springframework.dao.DataIntegrityViolationExce ption: executing PreparedStatementCallback [PreparedStatementCreatorFactory.PreparedStatementC reatorImpl: sql=[insert into documentimageaudit(USERNAME,COMPUTER,AUDITDATETIME ,AUDITEVENT_ID,DOCUMENTIMAGE_ID,AUDITSTR) values(?,?,?,?,?,?)]: params=[ANDY,null,2005-03-02 15:24:21.746,1000001,1,View Document]]: ORA-00001: unique constraint (CRIMES.PK_DOCUMENTIMAGEAUDIT) violated
    ; nested exception is java.sql.SQLException: ORA-00001: unique constraint (CRIMES.PK_DOCUMENTIMAGEAUDIT) violated
    ]

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Triggering beforeCompletion synchronization

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHold er@135] for key [org.springframework.jdbc.datasource.DriverManagerD ataSource@95] from thread [HttpRequestHandler-300]

    2005-03-02 15:24:21,793 DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Closing JDBC connection

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Initiating transaction rollback

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Rolling back JTA transaction

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.jta.JtaTransaction Manager - Triggering afterCompletion synchronization

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Clearing transaction synchronization

    2005-03-02 15:24:21,793 WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class org.springframework.dao.DataIntegrityViolationExce ption

  • #2
    I imagine its sonething to do with the following log entry:

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute - Winning rollback rule is: null

    2005-03-02 15:24:21,793 DEBUG org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute - No relevant rollback rule found: applying superclass default

    Comment


    • #3
      Hi,

      I think your problem is that your DAO are using a DriverManagerDataSource:
      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">

      JTA knows nothing about your "rogue" connection to the DB and actually no TX is taking place.

      You want to use JTA to handle your transaction, so I guess you're in a managed enviroment and you're using some J2EE APP Server. If you want your DB session to join the JTA Tx you have to request the DB connection from the App Server. So first make the datasource using your J2EE server facilities and then declare the datasource in Spring as a JNDI DS:
      <bean id="APPServDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">

      Try again and let us know...

      -regards,

      Gerard.

      Comment


      • #4
        Hi Gerard

        Thanks, that solved my problem.

        I was using a datasource of:

        Code:
        org.springframework.jdbc.datasource.DriverManagerDataSource
        with a transaction manager of:

        Code:
        org.springframework.transaction.jta.JtaTransactionManager
        I found that the following combinations work:

        Code:
        org.springframework.jndi.JndiObjectFactoryBean
        org.springframework.transaction.jta.JtaTransactionManager
        OR
        Code:
        org.springframework.jdbc.datasource.DriverManagerDataSource
        org.springframework.jdbc.datasource.DataSourceTransactionManager
        I'd like to avoid using JNDI if possible, but still need pooled connections. Can you recomend a Datasource and Transaction manager that would do this ?

        Thanks

        Andy

        Comment

        Working...
        X