Cernunnos Manual


<sql-transaction>

Description:

Subtasks that operate on the specified DataSource will be transactional if they use the Cernunnos sql tasks or the Spring JDBC APIs.

Reagents:

Name XPath Description Reagent Type Expected Type Required
DATA_SOURCE @data-source Optional DataSource object. The default is the value of the 'SqlAttributes.DATA_SOURCE' request attribute. Only used if TRANSACTION_MANAGER is not specified. PHRASE javax.sql.DataSource No
ATTRIBUTE_NAME @attribute-name Optional name under which a newly created PlatformTransactionManager will be registered as a request attribute. If omitted, the name 'SqlAttributes.TRANSACTION_MANAGER' will be used. PHRASE java.lang.String No
TRANSACTION_MANAGER @transaction-manager Optional PlatformTransactionManager object. If not specified a DataSourceTransactionManager is created using the specified DATA_SOURCE. PHRASE org.springframework.transaction.PlatformTransactionManager No
SUBTASKS * The set of tasks that are children of this task. NODE_LIST java.util.List No

Examples:

Loads a Spring bean container defined in 'datasourceContext.xml' which contains a DataSource, then begins a transaction, then queries that DataSource for the 'user_id' associated with the 'admin' account, then performs an 'upsert' operation on the 'up_user_profile' table:

 
       
        <spring-beans location="datasourceContext.xml"> 
          <with-attribute key="SqlAttributes.DATA_SOURCE" value="${PortalDb}"> 
            <sql-transaction> 
              <sql-upsert> 
                <update-statement>UPDATE up_user_profile SET profile_name = 'HTML browser profile' WHERE user_id = ?</update-statement>  
                <insert-statement>INSERT INTO up_user_profile(user_id, profile_id, profile_name, description, layout_id, structure_ss_id, theme_ss_id) VALUES(?, 1, 'HTML browser profile', 'A sample profile for common web browsers', 1, 1 1)</insert-statement>  
                <parameter value="${sql(SELECT user_id FROM up_user WHERE user_name = 'admin')}"/> 
              </sql-upsert> 
            </sql-transaction> 
          </with-attribute> 
        </spring-beans>