0

下面是我对spring和spring_persistence.xml的配置。persist() 操作没有插入记录。也没有错误。。

WAS 8.5 应用服务器 Spring 3.1 Hibernate 3.6.7

请帮忙 !

<tx:annotation-driven  transaction-manager="transactionManager"/>
<context:annotation-config /> 

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" >
    </bean>



<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
    <property name="dataSource" ref="dataSource"/>
    <property  name="persistenceUnitName" value="perstemplate"/>
    <property name="persistenceXmlLocation" value="classpath*:META-INF/myspring_persistence.xml"/>
      </bean> 

<persistence-unit name="perstemplate" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <class>com.mycompany.EntityClass</class>
     </persistence-unit>  
4

1 回答 1

0

当您使用 Container 中的 TransactionManager 时,您需要将 transaction-type 设置为JTA.

于 2013-05-06T07:43:43.720 回答