2013年11月21日星期四

spring transaction

The project is now in such a situation , , has been configured this transaction management , then that is A calls B, B calls C, I think A is a transaction , B to use try catch, do not use a transaction , C also use transactions , but does not , and A is a transaction. In this case how to solve ah. Find Great God help
------ Solution ------------------------------------- -------
you is how ? c the transaction, commit not affect A?, called a anomaly , a transaction rollback , c have the transaction commits .
call , c is an exception , the transaction is rolled back , b handle an exception , a transaction can still submit ?
Is that right ?
then your transaction propagation , it is necessary to make a change ,
a of propagation = "REQUIRES_NEW" Using the new transaction
------ Solution ------------------------- -------------------
in the B method definition , add annotation @ Transactional (propagation = Propagation.REQUIRES_NEW), creates a new transaction ; while in the configuration file annotation -based configuration method using transaction statement
- ---- For reference only ---------------------------------------
< br /> modify , the fact is that A calls C and B, c does not use a transaction , B using transactions , but do not want A and B in a single transaction . B is abnormal , just rollback B, A does not roll
------ For reference only ------------------------ ---------------
modification , the fact is that A calls C and B, c does not use a transaction , B using transactions , but do not want A and B in a single transaction . Exception is B , just rollback B, A does not roll
------ For reference only ---------------------- -----------------
then add the next , A, B in a class , C , and AB is not a class
------ For reference only ---------------------------------------
landlord profound ah. . .
------ For reference only -------------------------------------- -

quickly answer questions ah
------ For reference only -------------------------- -------------
hierarchical execution , and then configure each method's transaction , probably so the ,
------ For reference only ------ ---------------------------------

Well, if the above plus annotations in the B Method way can it , I have to call the next, seemingly not, or give me all rolled back
------ For reference only ----------------- ----------------------

9 F, positive solution, the test no problem. thanks

没有评论:

发表评论