transactions

EF and TransactionScope for both SQL Server and Oracle without escalating/spanning to DTC?

心已入冬 提交于 2019-12-29 01:27:31
问题 Can anyone update me on this topic? I want to support both SQL Server and Oracle in my application. Is it possible to have the following code (in BL) working for both SQL Server and Oracle without escalating/spanning to distributed transactions (DTC) ? // dbcontext is created before, same dbcontext will be used by both repositories using (var ts = new TransactionScope()) { // create order - make use of dbcontext, possibly to call SaveChanges here orderRepository.CreateOrder(order); // update

EF and TransactionScope for both SQL Server and Oracle without escalating/spanning to DTC?

你。 提交于 2019-12-29 01:26:09
问题 Can anyone update me on this topic? I want to support both SQL Server and Oracle in my application. Is it possible to have the following code (in BL) working for both SQL Server and Oracle without escalating/spanning to distributed transactions (DTC) ? // dbcontext is created before, same dbcontext will be used by both repositories using (var ts = new TransactionScope()) { // create order - make use of dbcontext, possibly to call SaveChanges here orderRepository.CreateOrder(order); // update

Spring hibernate , how to call some method after transaction commit or transaction rollback

ε祈祈猫儿з 提交于 2019-12-28 13:51:41
问题 I need to call some method after transaction succes or rollback. I am using as <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <property name="sessionFactory"> <ref local="mysessionFactory"/> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="mysessionFactory"/> </property> </bean> <tx:annotation-driven

mysql insert race condition

痴心易碎 提交于 2019-12-28 12:34:47
问题 How do you stop race conditions in MySQL? the problem at hand is caused by a simple algorithm: select a row from table if it doesn't exist, insert it and then either you get a duplicate row, or if you prevent it via unique/primary keys, an error. Now normally I'd think transactions help here, but because the row doesn't exist, the transaction don't actually help (or am I missing something?). LOCK TABLE sounds like an overkill, especially if the table is updated multiple times per second. The

Refactoring ADO.NET - SqlTransaction vs. TransactionScope

六月ゝ 毕业季﹏ 提交于 2019-12-28 05:15:09
问题 I have "inherited" a little C# method that creates an ADO.NET SqlCommand object and loops over a list of items to be saved to the database (SQL Server 2005). Right now, the traditional SqlConnection/SqlCommand approach is used, and to make sure everything works, the two steps (delete old entries, then insert new ones) are wrapped into an ADO.NET SqlTransaction. using (SqlConnection _con = new SqlConnection(_connectionString)) { using (SqlTransaction _tran = _con.BeginTransaction()) { try {

TSQL Try / Catch within Transaction or vice versa?

不想你离开。 提交于 2019-12-28 03:42:10
问题 I'm writing a script that will delete records from a number of tables, but before it deletes it must return a count for a user to confirm before committing. This is a summary of the script. BEGIN TRANSACTION SCHEDULEDELETE BEGIN TRY DELETE -- delete commands full SQL cut out DELETE -- delete commands full SQL cut out DELETE -- delete commands full SQL cut out PRINT 'X rows deleted. Please commit or rollback.' --calculation cut out. END TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumber,

What does a transaction around a single statement do?

六眼飞鱼酱① 提交于 2019-12-27 13:07:54
问题 I understand how a transaction might be useful for co-ordinating a pair of updates. What I don't understand is wrapping single statements in transactions, which is 90% of what I've ever seen. In fact, in real life code it is more common in my experience to find a series of logically related transactions each wrapped in their own transaction, but the whole is not wrapped in a transaction. In MS-SQL, is there any benefit from wrapping single selects, single updates, single inserts or single

What does a transaction around a single statement do?

限于喜欢 提交于 2019-12-27 13:04:13
问题 I understand how a transaction might be useful for co-ordinating a pair of updates. What I don't understand is wrapping single statements in transactions, which is 90% of what I've ever seen. In fact, in real life code it is more common in my experience to find a series of logically related transactions each wrapped in their own transaction, but the whole is not wrapped in a transaction. In MS-SQL, is there any benefit from wrapping single selects, single updates, single inserts or single

Calling a procedure inside a function throws MySQL ERROR 1422

风格不统一 提交于 2019-12-25 16:44:10
问题 I am building a "bank" as an assignment for a database course I am taking. I have created a stored function which takes a few IN variables, such as account ID, customer ID and a PIN number, and does checks on this to see if the submitted data is valid. If the data is valid, the procedure updates the account balance to represent a monetary transaction. It then "returns" whether or not the submitted data was valid. Here is the code for the procedure: DELIMITER // CREATE PROCEDURE retrieveMoney

Calling a procedure inside a function throws MySQL ERROR 1422

青春壹個敷衍的年華 提交于 2019-12-25 16:43:04
问题 I am building a "bank" as an assignment for a database course I am taking. I have created a stored function which takes a few IN variables, such as account ID, customer ID and a PIN number, and does checks on this to see if the submitted data is valid. If the data is valid, the procedure updates the account balance to represent a monetary transaction. It then "returns" whether or not the submitted data was valid. Here is the code for the procedure: DELIMITER // CREATE PROCEDURE retrieveMoney