java - example of spring declarative roolback-for? -


want declarative transactional management example in spring aop........

actually here

<aop:config>     <aop:advisor advice-ref="addadvice" pointcut="execution(* com.dao.*.*(..))"/> </aop:config> <tx:advice id="addadvice" transaction-manager="transactionmanager">     <tx:attributes>         <tx:method name="add*" propagation="required" rollback-for="" />     </tx:attributes> </tx:advice> 

so here want write rollback-for="" , there method or else? , if method method put?

in rollback-for specify name of exception. example if you want rollback your.pkg.noproductinstockexception, write

rollback-for="your.pkg.noproductinstockexception" 

this make transaction rolled if encounters exception matches specified. if exception thrown not match, propagated caller of service or wrapped transactionrolledbackexception

the transaction documentation explains:

the recommended way indicate spring framework's transaction infrastructure transaction's work rolled throw exception code executing in context of transaction. spring framework's transaction infrastructure code catch unhandled exception bubbles call stack, , make determination whether mark transaction rollback.

in default configuration, spring framework's transaction infrastructure code marks transaction rollback in case of runtime, unchecked exceptions; is, when thrown exception instance or subclass of runtimeexception. (errors - default - result in rollback). checked exceptions thrown transactional method not result in rollback in default configuration.

you can configure exception types mark transaction rollback, including checked exceptions.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -