transactions

Handling Transaction Between Paypal and Local Datasase

旧街凉风 提交于 2020-01-24 13:34:13
问题 What is the best practice to handle transaction between application and paypal. Consider: I'm Alice and I want send money to Bob In my DB I see that Bob has $200 and I want to send him $150. Once transaction is sent I want to update the Bob's account such that it would contain $50. Now according to PayPal API I can send Pay and receive success. However what happens if I for example send Pay it succeeds but I fail to receive a response due to network problem. So I assume that error happened

Transaction-Style HTTP requests

半腔热情 提交于 2020-01-24 10:39:32
问题 I recently ran into such problem: For each user, I need to do the following on server side: First (SQL) Insert user's record with a Unique constraint on ID Then Parallel (Http) Subscribe user to Service A, get subscription_id_A (Http) Subscribe user to Service B, get subscription_id_B Finally (SQL) Update user's record with both subscription ids Ideally I want this entire operation to be transactional, eg if any of http requests or sql fails, it would be as if nothing happened. Added: if

Transaction-Style HTTP requests

我的未来我决定 提交于 2020-01-24 10:38:28
问题 I recently ran into such problem: For each user, I need to do the following on server side: First (SQL) Insert user's record with a Unique constraint on ID Then Parallel (Http) Subscribe user to Service A, get subscription_id_A (Http) Subscribe user to Service B, get subscription_id_B Finally (SQL) Update user's record with both subscription ids Ideally I want this entire operation to be transactional, eg if any of http requests or sql fails, it would be as if nothing happened. Added: if

Java configuration for jdbctemplate and transaction management in spring

陌路散爱 提交于 2020-01-24 08:51:49
问题 I am using spring jdbc with spring jdbc transaction support. Here is my configuration. @Configuration @EnableTransactionManagement(mode = AdviceMode.ASPECTJ) @EnableGlobalMethodSecurity(securedEnabled = true) @PropertySource(name = "props", value = { "classpath:common/jdbc.properties", "classpath:common/mail.properties", "classpath:common/message.properties", "classpath:common/common.properties" }) public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { @Value("${jdbc.url}")

What is the difference between withTransaction and withNewTransaction?

亡梦爱人 提交于 2020-01-24 04:02:06
问题 What is the difference between the following actions? def someAction() { User.withTransaction { ... } } and def someAction() { User.withNewTransaction { ... } } When do I use what? When a grails action contains only a Transaction block. In this case I guess withTransaction and withNewTransaction are the same, because each action has its own transaction. Is this true? 回答1: I believe these functions have to do with transaction isolation semantics. The withTransaction function will participate

Is it possible to measure time of all Spring managed transactions with @Transactional?

空扰寡人 提交于 2020-01-23 17:46:35
问题 I would like to measure time of transacactions managed by Spring with JpaTJpaTransactionManager / PlatformTransactionManager to detect long pending transactions and warn some listener about that condition. I could use aspect on @Transactional methods but due to transaction propagation it's not a good way to detect when exact transaction is started or finished. It would be good to something like transaction listener with access to start/finish events together with some bean name of object

Why does Hibernate only Auto-Flush inside a transaction?

*爱你&永不变心* 提交于 2020-01-23 07:08:50
问题 What is the rationale behind this behavior? If for some reason I execute two suitable operations outside a transaction (not recommended, I know!) and I've configured Hibernate to auto-flush, I would expect it to auto-flush if the second operation is one that should trigger an auto-flush (like list , iterate , or executeUpdate ). That's exactly what would happen, if not for the explicit check on the second line of the autoFlushIfRequried method: protected boolean autoFlushIfRequired(Set

Repository pattern with MongoDB - multiple units of work with one transaction

℡╲_俬逩灬. 提交于 2020-01-23 05:28:15
问题 I'm implementing a DAL abstraction layer on top of the C# Mongo DB driver using the Repository + Unit of Work pattern. My current design is that every unit of work instance opens (and closes) a new Mongo DB session. The problem is that Mongo DB only allows a 1:1 ratio between a session and a transaction, so multiple units of work under the same .NET transaction will not be possible. The current implementation is: public class MongoUnitOfWork { private IClientSessionHandle _sessionHandle;

SQL Server - Nested transactions in a stored procedure

喜你入骨 提交于 2020-01-22 18:45:10
问题 Lets say this is the situation: [Stored Proc 1] BEGIN BEGIN TRANSACTION ... exec sp 2 COMMIT END Now, if SP 2 - rolls back for whatever reason, does SP 1 - commit or rollback or throw exception? Thanks. 回答1: There are no autonomous transactions in SQL Server. You may see @@TRANCOUNT increase beyond 1, but a rollback affects the whole thing. EDIT asked to point to documentation. Don't know of the topic that documents this explicitly, but I can show it to you in action. USE tempdb; GO Inner

SQL Server - Nested transactions in a stored procedure

一个人想着一个人 提交于 2020-01-22 18:43:46
问题 Lets say this is the situation: [Stored Proc 1] BEGIN BEGIN TRANSACTION ... exec sp 2 COMMIT END Now, if SP 2 - rolls back for whatever reason, does SP 1 - commit or rollback or throw exception? Thanks. 回答1: There are no autonomous transactions in SQL Server. You may see @@TRANCOUNT increase beyond 1, but a rollback affects the whole thing. EDIT asked to point to documentation. Don't know of the topic that documents this explicitly, but I can show it to you in action. USE tempdb; GO Inner