java - Rolling back transactions after exception is thrown -


when throw exception in service method expected transactional annotation on service rollback save operation, not working.

this service:

  @service   @transactional(value = "transactionmanager", rollbackfor = exception.class)     public class orderserviceimp implements orderservice {          @autowired         private orderrepository orderrepository;          @override         public void dosomestaff(long orderid) {              order order = orderrepository.findone(orderid);              orderrepository.save(order);              throw new nullpointerexception("test transaction exeption");         }     } 

in data.xml have next configs:

<tx:annotation-driven transaction-manager="transactionmanager" />      <bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager">         <property name="entitymanagerfactory" ref="entitymanagerfactory" />     </bean>   <jpa:repositories base-package="com.dmitro.repositories" entity-manager-factory-ref="entitymanagerfactory" transaction-manager-ref="transactionmanager"/> 

in dispatcher-servlet.xml declared scan:

<context:component-scan base-package="com.dmitro.service" /> 

i using spring-data-jpa 1.8.0.release. please help!

@transactional(value = "transactionmanagerforservicelayer", rollbackfor = exception.class) 

this culprit. should not have different transaction manager service , repository. fix it, need replace transactionmanagerforservicelayer here transactionmanager , rollback work.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -