transactions

Entity Framework : interrupt running SaveChanges

I have a unique ObjectContext, on which I perform a SaveChanges(). This operation takes some time (~60 seconds). This operation is executed in a thread. My user have a "Cancel" button on the screen. I'm able to stop the thread, but if the SaveChanges() has already started I can't find anyway to cancel it. In fact I found no way to acces...

Data access strategy for a site like SO - sorted SQL queries and simultaneous updates that affect the sort?

I'm working on a Grails web app that would be similar in access patterns to StackOverflow or MyLifeIsAverage - users can vote on entries, and their votes are used to sort a list of entries based on the number of votes. Votes can be placed while the sorted select queries are being performed. Since the selects would lock a large portion ...

JTA Transaction: What happens if an exception happens but rollback is not called on the transaction?

We have some third party code wherein they do the following 1) Create a User Transaction e.g. txn = (UserTransaction)ctx.lookup( "UserTransaction" ); txn.begin( ); 2) Do some work persisting to the database (via JPA) to a MySQL database 3) txn.commit() They have Exception blocks but NONE of them call txn.rollback. Good c...

wrapping user controls in a transaction

I'm working on heavily dynamic and configurable CMS system. Therefore, many pages are composed of a dynamically loaded set of user controls. To enable loose coupling between containers (pages) and children (user controls), all user controls are responsible for their own persistence. Each User Control is wired up to its data/service lay...

PostgreSQL insert on primary key failing with contention, even at serializable level

I'm trying to insert or update data in a PostgreSQL db. The simplest case is a key-value pairing (the actual data is more complicated, but this is the smallest clear example) When you set a value, I'd like it to insert if the key is not there, otherwise update. Sadly Postgres does not have an insert or update statement, so I have to e...

How to avoid ASP.NET SqlServer session to interfer with the ambient Transaction-Per-Request?

Hi, I am trying to use a transaction scope in a transaction-per-request pattern. So I have a http module that do (simplified): private void Application_BeginRequest(object sender, EventArgs e) { var scope = new TransactionScope(TransactionScopeOption.RequiresNew); PutScopeInHttpContext(scope); } private void Application_EndReq...

NHibernateUnitOfWork + ASP.Net MVC

Hi Guys, hows it going? I'm in my first time with DDD, so I'm begginer! So, let's take it's very simple :D I developed an application using asp.net mvc 2 , ddd and nhibernate. I have a domain model in a class library, my repositories in another class library, and an asp.net mvc 2 application. My Repository base class, I have a construct...

How to have transactions on objects

Hi, How I can imitate transactions on objects. For example, I want to delete the item from one collection and then add the same item to other collection as an atomic action. It is possible to do a lot of checks when something failed and to roll back everything but this is annoying. Is there any technique (no difference what language (Ja...

Passing around a SqlConnection

I have created a TransactionScope and within the scope various items are created and updated in the database. During this process I make a lot of calls to the database. Originally I opened a SqlConnection in the beginning of the TransactionScope and passed it around to any function that made a DB call then I closed the connection after a...

Which isolation level should I use for the following insert-if-not-present transaction?

I've written a linq-to-sql program that essentially performs an ETL task, and I've noticed many places where parallelization will improve its performance. However, I'm concerned about preventing uniquness constraint violations when two threads perform the following task (psuedo code). Record CreateRecord(string recordText) { using ...

Should I commit or rollback a transaction that creates a temp table, reads, then deletes it?

To select information related to a list of hundreds of IDs... rather than make a huge select statement, I create temp table, insert the ids into it, join it with a table to select the rows matching the IDs, then delete the temp table. So this is essentially a read operation, with no permanent changes made to any persistent database tabl...

MySQL Simple query gives "Query was empty". Transaction help needed I think.

Hi, I'm trying to do a simple transaction in MySQL delimiter go start transaction; BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND ROLLBACK; INSERT INTO jext_categories (Name) VALUES ('asdfas'); INSERT INTO jext_categories (Name) VALUES ('asdfas2'); END; commit; SELECT * FROM jext_c...

Can I use TransactionScope to do distributed transaction?

Hi I have a MVC app that uses Linq2Sql to access a SQL DB. But I want create a distributed transaction to update another DB on different local server. I want to update both in a transaction. Can I just wrap logic in TransactionScope class??? Malcolm ...

How can I have 2 ADO access methods use the same Transaction?

I'm writing a test to see if my LINQ to Entity statement works.. I'll be using this for others if I can get this concept going.. my intention here is to INSERT a record with ADO, then verify it can be queried with LINQ, and then ROLLBACK the whole thing at the end. I'm using ADO to insert because I don't want to use the object or the e...

Can a Snapshot transaction fail and only partially commit in a TransactionScope?

Greetings I stumbled onto a problem today that seems sort of impossible to me, but its happening...I'm calling some database code in c# that looks something like this: using(var tran = MyDataLayer.Transaction()) { MyDataLayer.ExecSproc(new SprocTheFirst(arg1, arg2)); MyDataLayer.CallSomethingThatEventuallyDoesLinqToSql(arg1, argEtc);...

Best practices to delete a set of tables in sql 2008

Basically I want to keep the transaction very simple but I should be able to rollback if any error occurs in the later part. Something like: BEGIN TRANSACTION DELETE SET 1(this will delete first set of table) COMMIT DELETE SET 2 (will delete second set of table) If any error occurs while deleting set 2 I should be able to roll...

MS Access (Jet) transactions, workspaces

I am having trouble with committing a transaction (using Access 2003 DAO). It's acting as if I never had called BeginTrans -- I get error 3034 on CommitTrans, "You tried to commit or rollback a transaction without first beginning a transaction"; and the changes are written to the database (presumably because they were never wrapped in a ...

How to handle dynamic site localizations?

I've got a website that is currently all in English. It is an online game, so it has a bunch of different pages with static text, as well as a lot of content in a database. I am trying to expand more globally and am gearing up to release some localizations of the site. However, I'm not sure about the best way to go about setting thi...

Exception Could not open Hibernate Session for transaction .

Sometime i m getting this problem in my NHibernate log .My application stops at that moment. Updated wityh data configuration. Even after successful transaction.Application connection with the database persist.in Nhibernate log it shows Nhibernate Log 2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl [(null)] <...

How to lock a transaction for reading a row and then inserting in Hibernate?

I have a table with a name and a name_count. So when I insert a new record, I first check what the maximum name_count is for that name. I then insert the record with that maximum + 1. Works great... except with mysql 5.1 and hibernate 3.5, by default the reads don't respect transaction boundaries. 2 of these inserts for the same nam...