transactions

SQL Server: Deleting Rows with Foreign Key Constraints: Can Transactions override the constraints?

I have a few tables where Foreign Key constraints are added. These are used with code generation to set up specific joins in generated stored procedures. Is it possible to override these constraints by calling multiple deletes within a transaction, specifically "TransactionScope" in C# or is cascaded deleting absolutely required? ...

Does a TransactionScope that exists only to select data require a call to Complete()

In order to select data from part of an application that isn't affected by dirty data, I create a TransactionScope that specifies a ReadUncommitted IsolationLevel as per the suggestion from Hanselman here. My question is, do I still need to execute the oTS.Complete() call at the end of the using block even if this transaction scope was ...

Nested/Child TransactionScope Rollback

I am trying to nest TransactionScopes (.net 4.0) as you would nest Transactions in SQL Server, however it looks like they operate differently. I want my child transactions to be able to rollback if they fail, but allow the parent transaction to decide whether to commit/rollback the whole operation. The problem is when the first complete...

Sql Server: chunking deletes still fills up transaction log; on fail all deletes are rolled back - why?

Here is my scenario: we have a database, let's call it Logging, with a table that holds records from Log4Net (via MSMQ). The db's recovery mode is set to Simple: we don't care about the transaction logs -- they can roll over. We have a job that uses data from sp_spaceused to determine if we've met a certain size threshold. If the thre...

Whats the proper way to do explicit transactions with linq to sql?

I have some scenarios where I need to have multiple calls to .SubmitChanges() on a datacontext, but I want to explicitly control the transaction myself to make it atomic. For a while I have been doing this by creating a connection, creating a transaction on that connection, then creating the datacontext and passing it both. Lets assume f...

How can the Three-Phase Commit Protocol (3PC) guarantee atomicity?

I'm currently exploring worst case scenarios of atomic commit protocols like 2PC and 3PC and am stuck at the point that I can't find out why 3PC can guarantee atomicity. That is, how does it guarantee that if cohort A commits, cohort B also commits? Here's the simplified 3PC from the Wikipedia article: Now let's assume the following ...

Is it necessary to write ROLLBACK if queries fail?

I write mysql_query("SET AUTOCOMMIT=0"); mysql_query("START TRANSACTION"); before I write all queries. Then check if all of them are true and then write: mysql_query("COMMIT"); But if one of query fails, I just pass COMMIT query. So do I really need ROLLBACK function if one of the queries fail? Because without ROLLBACK it also works....

Question about spring transaction propagation

Hi guys, I have a question about spring transaction propagation. If I use @Transactional(propagation = Propagation.REQUIRED) to annotate a method m1. When execution logic enter m1, if there is already a transaction, m1 will use that one. When after m1, what about the transaction? It ends or still open?(if I call m1 in another method, an...

How does rolling back an application level transaction interact with SqlDataAdapter events in ADO.NET, or does it at all?

When utilizing the RowUpdated event in the SqlAdapter class, i'm assuming that it is raised directly following the return of the database interaction that executes the update. If that update is part of an application level transaction (utilizing the SqlTransaction class) which is then rolled back, does this affect or interact at all wit...

opening transaction validation in vb.net

Can anyone help me on how can I validate transaction example: transaction = mySqlConn.BeginTransaction(IsolationLevel.ReadCommitted) If there's still an opened transaction, then the code above will ignore.. How do I know if there was a transaction not yet committed before opening new transaction to avoid Nested Transaction? ...

Declarative security on service operation via PrincipalPermission uses client propagated transaction

I am implementing a WCF service that uses transaction propagation. The ASP .nET Security model with SQL Server (SqlRoleProvider) is used for authorization. I am using declarative security via the PrincipalPermission attribute, as shown below. [ServiceBehavior(TransactionIsolationLevel = IsolationLevel.Serializable)] public class MyServ...

Fixing "Lock wait timeout exceeded; try restarting transaction" for a 'stuck" Mysql table?

From a script I sent a query like this thousands of times to my local database: update some_table set some_column = some_value I forgot to add the where part, so the same column was set to the same a value for all the rows in the table and this was done thousands of times and the column was indexed, so the corresponding index was prob...

Can you modify SQL DB schema in a transaction to know if all changes were applied?

As part of my (new) database version control methodology, I'm writing a "change script" and want the change script to insert a new row into the SchemaChangeLog table if the script is executed successfully, or to reverse changes if any single change in the script fails. Is it possible to do schema changes in a transaction and only if it ...

Spring transaction management breaks hibernate cascade

I'm having a problem where the addition of spring's transaction management to an application causes Hibernate to throw the following error: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.fstrf.masterpk.domain.ReportCriteriaBean.treatmentArms org...

Hibernate deletion issue

I'm trying to write a Java app that imports a data file. The process is as follows Create Transaction Delete all rows from datatable Load data file into datatable Commit OR Rollback if any errors were encountered. The data loaded in step 3 is mostly the same as the data deleted in step3. The deletion is performed using the followin...

how to ensure that Nhibernate is inside a transaction when saving, updating or deleting

I'd like to ensure that when I'm persisting any data to the database, using (Fluent)NHibernate, that the operations are executed inside a transaction. Is there anyway of checking that a transaction is active via an interceptor? Or any other eventing mechanism? More specifically, I'm using the System.Transaction.TransactionScope for tr...

Defines JEE 5 the handling of commit error using bean managed transactions?

I'm using glassfish 2.1 and 2.1.1. If I've a bean method annotated by @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW). After doing some JPA stuff the commit fails in the afterCompletion-Phase of JTS. GlassFish logs this failure only. And the caller of this bean method has no chance to know something goes wrong. So...

Reuse Hibernate session in thread

Hello, I've read somewhere that when a session is flushed or a transaction is committed, the session itself is closed by Hibernate. So, how can i reuse an Hibernate Session, in the same thread, that has been previously closed? Thanks ...

Transaction within a Transaction in C#

I'm importing a flat file of invoices into a database using C#. I'm using the TransactionScope to roll back the entire operation if a problem is encountered. It is a tricky input file, in that one row does not necessary equal one record. It also includes linked records. An invoice would have a header line, line items, and then a total...

How do I delete in Django? (mysql transactions)

If you are familiar with Django, you know that they have a Authentication system with User model. Of course, I have many other tables that have a Foreign Key to this User model. If I want to delete this user, how do I architect a script (or through mysql itself) to delete every table that is related to this user? My only worry is that...