Spring transaction

   First of all we know that In fact, Spring does not directly manage transactions, butprovides a variety of transaction managers< strong>. They delegate the responsibility of transaction management to the transaction of the relevant platform framework provided by persistence mechanisms such as Hibernate or JTA.

  Spring’s transaction is mainly divided into: programmatic transaction, declarative transaction

  第The transaction manager must be configured in one step (the dataSource is the transaction source)



"transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  "dataSource" ref="dataSource" />

   The configuration we use for programmatic transactions:

 1: Programmatic transaction management


"transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
  "transactionManager" ref="transactionManager">
  
  "isolationLevelName" value="ISOLATION_DEFAULT">
  "propagationBehaviorName" value="PROPAGATION_REQUIRED">

  My common configuration for declarative transactions is as follows:

   first share with you The declarative transactions summarized below have the following methods

    1, use bean proxy (one proxy per bean)

    2 Use bean proxy (multiple beans, one proxy)

    3, use interceptor

    4, use tx tag

strong>

    5. Use full annotations

  My usual configuration is 4, 5

    4. For the configuration of tx (personal use) 

2: Declarative transaction management: one is tx, the other is based on @Transactional annotations


  
  
"advice" transaction-manager="transactionManager">
  
    "insert" propagation= "REQUIRED" read-only="false" rollback-for="Exception"/>
  

    5, full annotations (individual Commonly used)

"transactionManager" />



"transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  "dataSource" ref="dataSource" />

1: Programmatic transaction management


"transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
  "transactionManager" ref="transactionManager">
  
  "isolationLevelName" value="ISOLATION_DEFAULT">
  "propagationBehaviorName" value="PROPAGATION_REQUIRED">

2: Declarative transaction management: one is tx, the other is based on @Transactional annotation


  
  
"advice" transaction-manager="transactionManager">
  
    "insert" propagation= "REQUIRED" read-only="false" rollback-for="Exception"/>
  

"transactionManager"/>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4730 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.