Announcement Announcement Module
Collapse
No announcement yet.
ibatis error trying to delete a row Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ibatis error trying to delete a row

    Hi,
    I am using spring to write a web application. I used JPetstore as a reference. Many thanks for the Spring team.

    I am using IBATIS sql maps. I tried to add a additonal method to DAO to delete an account (All the inserts, updates, and selects works fine in this application).



    -----------------------------------------------------
    This is what I add to the Account.xml file

    <mapped-statement name="deleteAccount">
    delete from ACCOUNT where userid=#value#
    </mapped-statement>

    <mapped-statement name="deleteSignOn">
    delete from SIGNON where username=#value#
    </mapped-statement>

    ------------------------------------------------------

    This is the additional methods in AccountDAO

    public void deleteAccount(String username) throws DataAccessException {
    getSqlMapTemplate().executeUpdate("deleteSignOn", username);
    getSqlMapTemplate().executeUpdate("deleteAccount", username);

    ---------------------------------------------------------

    I get the following error. Does any one have any idea.

    Thanks

    Sri...

    Error executing 'deleteSignOn' in 'com/pbs/portal/web/dao/ibatis/maps/Account.xml'. Check the SQL statement. Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

    java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
    at org.springframework.orm.ibatis.SqlMapTemplate.exec uteUpdate(SqlMapTemplate.java:221)
    at com.pbs.portal.web.dao.ibatis.SqlMapAccountDao.del eteAccount(SqlMapAccountDao.java:59)
    at com.pbs.portal.web.domain.logic.PortalImpl.deleteA ccount(PortalImpl.java:114)
    at java.lang.reflect.Method.invoke(Native Method)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:71 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:149)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:213)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:168)
    at $Proxy0.deleteAccount(Unknown Source)
    at com.pbs.portal.test.database.DatabaseTests.testIns ertInvestorAccount(DatabaseTests.java:60)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:164 )
    at junit.framework.TestCase.runBare(TestCase.java:132 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:107)
    at junit.framework.TestResult.runProtected(TestResult .java:135)
    at junit.framework.TestResult.run(TestResult.java:112 )
    at junit.framework.TestCase.run(TestCase.java:119)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 09)
    at junit.framework.TestSuite.run(TestSuite.java:205)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:399)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:288)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:170)
    at junit.framework.TestCase.run(TestCase.java:119)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 09)
    at junit.framework.TestSuite.run(TestSuite.java:205)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:170)
    [ WARN] 15:54 (SQLErrorCodeSQLExceptionTranslator.java:translate :161)
    Unable to translate SQLException with errorCode '0', will now try the fallback translator

  • #2
    Seems that your delete operation is executed in a read-only transaction... Do you use the "readOnly" flag in your transaction attributes? Check that the transaction attribute for your delete operation does not specify "readOnly"!

    Juergen

    Comment


    • #3
      The solution.

      Thanks Juergen,

      This is what I have to do to fix the problem (If in case someone encounters the same problem.)
      Add this line

      <prop
      key="delete*">PROPAGATION_REQUIRED
      </prop>


      into your application.xml file for the bean

      org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean

      Comment

      Working...
      X