首页 新闻 会员 周边 捐助

ORA-01453: SET TRANSACTION 必须是事务处理的第一个语句 Spring.net mvc nhiberate 配置事务

0
悬赏园豆:50 [待解决问题]

我想到事务放在Service层,运行出错,请高手帮忙,谢谢!下面是配置文件

=============Services.xml=============

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:tx="http://www.springframework.net/tx">

  <!-- Referenced by main application context configuration file -->

  <description>
    The Northwind service layer definitions
  </description>

  <!-- Property placeholder configurer for database settings -->
  <object id="MaterialTypeService" type="Storage.Service.Material.MaterialTypeService, Storage.Service">
    <property name="MaterialTypeDao" ref="MaterialTypeDao"/>
  </object>

  <tx:attribute-driven/>
</objects>

 

==============Dao.xml===============

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">

  <!-- Referenced by main application context configuration file -->
  <description>
    The Northwind object definitions for the Data Access Objects.
  </description>

  <!-- Property placeholder configurer for database settings -->
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <!-- Database Configuration -->
  <!--<db:provider id="DbProvider" provider="System.Data.OracleClient"
               connectionString="Data Source=${db.datasource};User ID=${db.user};Password=${db.password};"/>-->
  <db:provider id="DbProvider" provider="System.Data.OracleClient"
               connectionString="Data Source=192.168.1.150/DBINOUT;User ID=meng;Password=meng;"/>

  <!-- NHibernate Configuration -->
  <object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate31">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>Storage.Domain</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.Oracle10gDialect"/>
        <entry key="connection.driver_class" value="NHibernate.Driver.OracleClientDriver"/>
        <entry key="use_outer_join" value="true"/>
        <entry key="show_sql" value="true"/>
        <entry key="hbm2ddl.auto" value="update"/>
        <entry key="hibernate.current_session_context_class"
              value="Spring.Data.NHibernate.SpringSessionContext, Spring.Data.NHibernate31"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>
       
  <!-- Transaction Management Strategy - local database transactions -->
  <object id="transactionManager"
        type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate31">

    <property name="DbProvider" ref="DbProvider"/>
    <property name="SessionFactory" ref="NHibernateSessionFactory"/>

  </object>
  <!--  通过TransactionProxyFactoryObject使用声明式事务-->
  <object id="txProxyTemplate" abstract="true"
            type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
    <property name="PlatformTransactionManager" ref="transactionManager"/>
    <property name="TransactionAttributes">
      <name-values>
        <add key="Update*" value="PROPAGATION_REQUIRED"/>
        <add key="Save*" value="PROPAGATION_REQUIRED"/>
        <add key="Delete*" value="PROPAGATION_REQUIRED"/>
        <add key="Get*" value="PROPAGATION_REQUIRED,readOnly"/>
        <add key="*" value="PROPAGATION_REQUIRED"/>
      </name-values>
    </property>
  </object>


  <!-- Exception translation object post processor -->
  <object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>
 
  <!-- Data Access Objects -->
  <object id="MaterialTypeDao" parent="txProxyTemplate">
    <property name="Target">
      <object type="Storage.Dao.Material.MaterialTypeDao, Storage.Dao">
        <property name="SessionFactory" ref="NHibernateSessionFactory"/>
      </object>
    </property>
  </object>


</objects>

jianding的主页 jianding | 初学一级 | 园豆:154
提问于:2012-06-04 23:48
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册