Announcement Announcement Module
Collapse
No announcement yet.
Questions about spring-tx in Spring MVC application step-by-step tutorial Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Questions about spring-tx in Spring MVC application step-by-step tutorial

    When I switched the database to mysql 5 with mysql-connector-java-5.1.6, something wrong happened with messages below:

    java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

    and the transaction config part in applicationContext:
    <tx:advice id="txAdvice">
    <tx:attributes>
    <tx:method name="save*"/>
    <tx:method name="*" read-only="true"/>
    </tx:attributes>
    </tx:advice>
    OR
    <tx:advice id="txAdvice">
    <tx:attributes>
    <tx:method name="*" read-only="true"/>
    <tx:method name="save*" propagation="REQUIRED"/>

    </tx:attributes>
    </tx:advice>

    when I modified it (explicitly map the get* method) to:
    <tx:advice id="txAdvice">
    <tx:attributes>
    <tx:method name="save*"/>
    <tx:method name="get*" read-only="true"/>
    </tx:attributes>
    </tx:advice>
    EVEN
    <tx:advice id="txAdvice">
    <tx:attributes>
    <tx:method name="*" propagation="REQUIRED"/>
    <tx:method name="save*" read-only="true"/>
    </tx:attributes>
    </tx:advice>
    Everything is Ok again. I tried different orders of the read and wirte config and it seems irrelevant. I think maybe there's something wrong with the precedence, the wildcard character (*) seems override the other identifiers.
    Maybe the tutorial didn't use it properly.
Working...
X