nested-transactions

Rails 3. Nested transactions. Exception in a child block

ぐ巨炮叔叔 提交于 2020-01-21 12:46:50
问题 Why doesn't ActiveRecord rollback changes in nested transactions after exception was risen in a child block? Here are examples: 1. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction do ?> Client.create(:name => 'Elena') >> raise ActiveRecord::Rollback >> end >> end => nil >> Client.all.map(&:name) => ["Pavel", "Elena"] # instead of [] 2. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction(:requires_new => true) do ?> Client.create(

Rails 3. Nested transactions. Exception in a child block

蹲街弑〆低调 提交于 2020-01-21 12:46:17
问题 Why doesn't ActiveRecord rollback changes in nested transactions after exception was risen in a child block? Here are examples: 1. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction do ?> Client.create(:name => 'Elena') >> raise ActiveRecord::Rollback >> end >> end => nil >> Client.all.map(&:name) => ["Pavel", "Elena"] # instead of [] 2. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction(:requires_new => true) do ?> Client.create(

Spring nested transaction rollback after handling exception

ε祈祈猫儿з 提交于 2019-12-24 09:45:12
问题 I have a @Service class which has a @Transactional method that calls another @Transactional method on the another service. Something like that: @Service public class AService { @Autowired BService b; @Autowired ARepository aRepo; @Transactional public void methodOne(){ try{ b.methodTwo(); }catch(RuntimeException e){} aRepo.save(new A()); } } @Service public class BService{ @Transactional public void methodTwo(){ if(true) throw new RuntimeException(); } } I expect that A entity will be insert,

how to manage nested transaction with try catch

[亡魂溺海] 提交于 2019-12-23 05:23:04
问题 --Drop Table Tab1 Begin Transaction TR1; Save Transaction TR1; Create Table Tab1(f1 decimal(10,0)); Begin Transaction TR2 Save Transaction TR2 insert into Tab1 values(1); Begin Transaction TR3; Save Transaction TR3; insert into Tab1 values(2); Begin Try insert into Tab1 values('OK'); Commit Transaction TR3; END TRY BEGIN Catch print 'catch' RollBack Transaction TR3; End Catch insert into Tab1 values(3); Commit Transaction TR2 insert into Tab1 values(4); Commit Transaction TR1; --Commit

Why nested transactions are not supported in JTA

旧城冷巷雨未停 提交于 2019-12-18 15:41:06
问题 Why aren't nested transactions supported by JTA? Is it because of the complexity of implementing them (which I doubt) or some design principle? 回答1: (As @Piotr Nowicki points out, JTA does allow nested transactions, but this is optional not mandatory.) Why? This is one of those questions that is impossible to answer with any certainty, unless you were one of the people "in the room" when the decisions were made. It could be the inherent complexity of including nested transactions as part of

Transaction Per Request Middleware Not working

南楼画角 提交于 2019-12-12 01:19:26
问题 I am trying to add a middleware so that transaction begins at the beginning of the request and commits or rollbacks depending on the situation. This is my middleware: public class TransactionPerRequestMiddleware { private readonly RequestDelegate next_; public TransactionPerRequestMiddleware(RequestDelegate next) { next_ = next; } public async Task Invoke(HttpContext context, AppDbContext dbContext) { var is_everything_ok = true; var transaction = dbContext.Database.BeginTransaction( System

Nested transaction scope .net

我与影子孤独终老i 提交于 2019-12-11 18:24:54
问题 I'm using SQL Server 2008 R2 and trying to use transactions. First a question about transactions in .net and SQL Server. If I have something like this try { var transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = IsolationLevel.ReadCommitted; transactionOption.Timeout = TransactionManager.MaximumTimeout; using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOption)) { //create question this creates a new question in the database

SQL Server 2005: Why Name Transactions?

一曲冷凌霜 提交于 2019-12-03 16:58:50
问题 I've been sorting out the whole nested transaction thing in SQL server, and I've gleamed these nuggets of understanding of behavior of nested trans': When nesting transactions, only the outermost commit will actually commit. "Commit Trans txn_name", when nested , will always apply to the innermost transaction, even if txn_name refers to an outer transaction. "ROLLBACK TRAN" (no name) , even in an inner transaction, will rollback all transactions. "ROLLBACK TRAN txn_name" - txn_name must refer

SQL Server 2005: Why Name Transactions?

断了今生、忘了曾经 提交于 2019-12-03 06:09:52
I've been sorting out the whole nested transaction thing in SQL server, and I've gleamed these nuggets of understanding of behavior of nested trans': When nesting transactions, only the outermost commit will actually commit. "Commit Trans txn_name", when nested , will always apply to the innermost transaction, even if txn_name refers to an outer transaction. "ROLLBACK TRAN" (no name) , even in an inner transaction, will rollback all transactions. "ROLLBACK TRAN txn_name" - txn_name must refer to the outermost txn name. If not, it will fail. Given these , is there any benefit of naming

SAVE TRANSACTION vs BEGIN TRANSACTION (SQL Server) how to nest transactions nicely

。_饼干妹妹 提交于 2019-12-03 05:08:46
问题 I have a stored procedure that needs to set a save point so that it can, under certain circumstances, undo everything it did and return an error code to the caller, or accept/commit it and return success to the caller. But I need it to work whether the caller has already started a transaction or not. The doc is extremely confusing on this subject. Here is what I think will work, but I'm not certain of all the ramifications. The thing is - this Stored Procedure (SP) is called by others. So I