java - Why does not "@Transactional(propagation = propagation.NEVER)" work? -


on spring docs, never propagation: execute non-transactionally, throw exception if transaction exists.

i wanted try following:

    @transactional(propagation = propagation.never)     public void getdeps(long id) {         system.out.println(databaseimp.getdepartmentbyid(id));     }      @transactional(propagation = propagation.required)     public void allprocessondb_second(long id) {         getdeps(id);         operation(id);     }    @transactional    public void operation(long id){         system.out.println(databaseimp.getdepartmentbyid(id));     } 

well, not important code want use @transactional(propagation = propagation.never) , use method in transactional method worked, mean must throw exception. , spring meta configuration file(xml) following:

<context:annotation-config></context:annotation-config>     <context:component-scan base-package="database.transactionmanagement"/>  <tx:annotation-driven transaction-manager="transactionmanager" mode="aspectj"/>  <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager">         <constructor-arg name="datasource" ref="datasource2"/>     </bean>   <bean id="datasource2" class="org.apache.tomcat.dbcp.dbcp2.basicdatasource" destroy-method="close">         <property name="driverclassname" value="com.mysql.jdbc.driver"/>         <property name="url" value="jdbc:mysql://localhost/hr"/>         <property name="username" value="root"/>         <property name="password" value=""/>     </bean> 

thanks answers.

@transactional annotations apply spring proxy objects. example, if call allprocessondb_second() spring bean injects service

@autowired  private myservice myservice;  ... myservice.allprocessondb_second(); 

then myservice spring proxy, , @transactional(propagation = propagation.required) applied. if call myservice.getdeps(id) @transactional(propagation = propagation.never) applied.

but when call first method, , second method it, second method isn't called through spring proxy rather directly, transactional configuration ignored.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -