java - Spring Transaction : rollbackfor and norollbackfor both defined -


here problem got in application have maintain:

i have first class annotation @transactional(rollbackfor = customexceptiona.class) in following code call method of @transactional(norollbackfor = customexceptionb.class) nb : customexceptiona or customexceptionb have 1 common ancestor wich exception.

and of course, when execute code exception raised wich neither of type customexceptiona or customexceptionb nor subclasses them.

so question simple : what happens transaction in case ? commit ? rollback ? hold on unfinished state waiting application (which answer might explain ugly things seen in application) ? , : why ?

thanks , time.

spring framework's transaction infrastructure code will, default, mark 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 transaction being rolled back.

why? makes perfect sense: checked exceptions mandatory handling or throwing out, if you're throwing checked exception out of transactional method, framework supposes know you're doing. in case of unchecled exceptionit's bug, or exception handling flaw, transaction rolled avoid data corruption.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -