2014-03-12 305 views
0

我在oracle中使用spring-data-jpa。我無法獲取@Transactional以默認回滾運行時異常。JPA spring @Transaction autocommit

下面是片段:

<persistence-unit name="dev2db" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <properties> 
      <property name="hibernate.archive.autodetection" value="class, hbm"/> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> 
      <property name="hibernate.hbm2ddl.auto" value="validate" /> 

      <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" /> 
      <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@host:port" /> 
      <property name="javax.persistence.jdbc.user" value="loginid" /> 
      <property name="javax.persistence.jdbc.password" value="mypass" /> 
     </properties> 
    </persistence-unit> 

事務方法採用進口javax.transaction.Transactional;

@Transactional 
    public void uploadPanelAndAPK(String pz, byte[] file, String apk, byte[] fileApk, byte[] icon) { 
     uploadPanel(pz, file); 
     uploadApk(apk, fileApk, icon); 

    } 

如果uploadApk失敗uploadPanel沒有執行回滾。

豆context.xml的片段:

<context:annotation-config /> 
    <tx:annotation-driven transaction-manager="transactionManager"/> 
    <jpa:repositories base-package="com.myco.dao" /> 

    <bean id="transactionManager" 
      class="org.springframework.orm.jpa.JpaTransactionManager" 
      p:entityManagerFactory-ref="entityManagerFactory"/> 


    <bean id="entityManagerFactory" 
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 
      p:persistenceUnitName="dev2db"> 
     <property name="jpaVendorAdapter"> 
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /> 
     </property> 
    </bean> 

    <bean id="panelbo" class="com.myco.bo.PanelServiceSpringData"/> 

問候,

米滕。

+0

也許是這樣的:'@Transactional(rollbackFor = RuntimeException.class,propagation = Propagation.REQUIRED)' – Athanor

回答

2

javax.transaction.Transactional尚未支持。使用javax.ejb.TransactionAttributeorg.springframewor.transaction.annotation.Transactional

相關問題