本帖最后由 tracy19880727 于 2013-07-10 10:43:41 编辑

解决方案 »

  1.   

    能说具体点吗?我有交给sessionFactory,你的意思是需要写dataSource吗?
      

  2.   

    没数据就表示没有提交   配置文件你加上aop试下  <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
    <ref local="sessionFactory" />
    </property>
    </bean>
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!-- all methods starting with 'get' are read-only -->
    <tx:method name="*TX" propagation="REQUIRED" />
    <!-- other methods use the default transaction settings (see below) -->
    <tx:method name="*" read-only="true" />
    </tx:attributes>
    </tx:advice>
    <aop:config>
    <aop:pointcut id="transactioncut"
    expression="execution(* *..*Service.*(..))" />
    <aop:advisor advice-ref="txAdvice"
    pointcut-ref="transactioncut" />
    </aop:config>
      

  3.   


    <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource">
            <property name="driverClassName">
                <value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
            </property>
            <property name="url">
                <value>jdbc:sqlserver://localhost:1433;databaseName=Tracy</value>
            </property>
            <property name="username">
                <value>sa</value>
            </property>
            <property name="password">
                <value>****</value>
            </property>
        </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
                <ref local="dataSource" />
            </property>
            <property name="mappingResources">
                <list>
                    <!--以下用来列出所有的PO映射文件-->
                    <value>com/lh/lsce/dto/ZipFileDto.hbm.xml</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">
                        org.hibernate.dialect.SQLServerDialect
                    </prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
    <property name="configLocation">
    <value>classpath:hibernate.cfg.xml</value>
    </property>
    请问这两种配置有什么区别?hibernate主文件是能找到的,使用上面一种没有问题,使用下面一种配置无法提交事物