Announcement Announcement Module
Collapse
No announcement yet.
why cann't rollback ? this Thansaction!!!!!!!!!!!!!!!!!!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why cann't rollback ? this Thansaction!!!!!!!!!!!!!!!!!!!

    why cann't rollback ? this Thansaction?

    Code:
    <bean id="silverSessionFactory" class="com.bjhuajia.silver.dao.SilverSessionFactory" factory-method="getDataSource">
    </bean>
    
    <bean id="transMan" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    	<property name="dataSource"><ref local="silverSessionFactory"/></property>
    </bean>
    
    <bean id="actionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
    	<property name="transactionManager">
    		<ref bean="transMan"/>
    	</property>
    	<property name="target">
    		<ref local="action" />
    	</property>
    	<property name="transactionAttributes">
    		<props>
    			<prop key="exe*">PROPAGATION_REQUIRED,-BaseException</prop>
    		</props>
    	</property>
    	<property name="proxyInterfaces"><value>com.bjhuajia.silver.control.I_Action</value></property>
    	
    </bean>

    Code:
    package com.bjhuajia.silver.dao;
    
    import java.sql.Connection;
    
    import javax.sql.DataSource;
    
    import org.springframework.jdbc.datasource.DataSourceUtils;
    
    public class SilverSessionFactory &#123;
        //private static Logger logger =
        // Logger.getLogger&#40;HibernateSessionFactory.class&#41;;
    
        public static final ThreadLocal tl = new ThreadLocal&#40;&#41;;
    
        public static DataSource getDataSource&#40;&#41; &#123;
            if &#40;tl.get&#40;&#41; == null&#41; &#123;
                tl.set&#40;DataSourceUtils.getDataSourceFromJndi&#40;"jdbc/silver"&#41;&#41;;
                return &#40;DataSource&#41; tl.get&#40;&#41;;
            &#125; else
                return &#40;DataSource&#41; tl.get&#40;&#41;;
        &#125;
    
        public static Connection getConnect&#40;&#41; &#123;
            return DataSourceUtils.getConnection&#40;getDataSource&#40;&#41;&#41;;
        &#125;
    
        public static void closeConn&#40;&#41; &#123;
            DataSourceUtils.closeConnectionIfNecessary&#40;getConnect&#40;&#41;,
                    getDataSource&#40;&#41;&#41;;
            tl.set&#40;null&#41;;
        &#125;
    
    &#125;

    does DataSourceUtils use same connection?

  • #2
    Could you extend more? client code, sample data...
    What bean are you using in your client? actionProxy?
    also, is it necessary to use SilverSessionFactory to get the DataSource? Spring has build-in support for looking up resources from JNDI.

    Comment

    Working...
    X