transactions

Have I to count transactions before rollback one in catch block in T-SQL?

I have next block in the end of each my stored procedure for SQL Server 2008 BEGIN TRY BEGIN TRAN -- my code COMMIT END TRY BEGIN CATCH IF (@@trancount > 0) BEGIN ROLLBACK DECLARE @message NVARCHAR(MAX) DECLARE @state INT SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE() ...

Forcing a method to be non-transactional in JPA (Eclipselink)

Hi, I am developing an application using Eclipselink and as part of the app I need to be able to manipulate some of the objects which involves changing data without it being persisted to the database (i merging/changing objects for some batch generation processes). I am reluctant to change the data in the Entity objects, as there is a...

Possible connection leaking causing "System.Data.SqlClient.SqlException: Timeout expired" error in SQL Server?

My application requires a user to log in and allows them to edit a list of things. However, it seems that if the same user always logs in and out and edits the list, this user will run into a "System.Data.SqlClient.SqlException: Timeout expired." error. I've read a comment about it possibly caused by uncommitted transactions. And I do ha...

How can i found out if there is transaction open in MySQL?

How can i find out if there is transaction open in mySQL? I need to start new one if there is no transaction open, but i don't want to start new one if there is one running, because that would commit that running transaction. UPDATE: i need to query database in one method of my application, but that query could be called as part of bi...

NHibernate Session per Call in WCF - How to Rollback

I've implemented some components to use WCF with both an IoC Container (StructureMap) and the Session per Call pattern. The NHibernate stuff is most taken from here: http://realfiction.net/Content/Entry/133. It seems to be OK, but I want to open a transaction with each call and commit at the end, rather than just Flush() which how it...

MySQL: automatic rollback on transaction failure

Is there any way to set MySQL to rollback any transaction on first error/warning automatically? Now if everything goes well, it commits, but on failure it leaves transaction open and on another start of transaction it commits incomplete changes from failed transaction. So i need to rollback automatically those failed transactions.. (I'...

NHibernate Linq queries not returning data saved in the same transaction

Hi, I have a situation where I am using NHibernate in a WCF service and using a TransactionScope for the transaction management. NHibernate enlists in the ambient transaction fine, but, any changes I make and save inside the transaction, are not visible to any queries I make while still in that transaction. So if I add an entity and ses...

Does a transaction stop all race condition problems in MySQL?

Consider this situation: Begin transaction Insert 20 records into a table with an auto_increment key Get the first insert id (let's say it's 153) Update all records in that table where id >= 153 Commit Is step 4 safe? That is, if another request comes in almost precisely at the same time, and inserts another 20 records after step 2 ...

In JPA, does rollback occur for the native queries?

I'm using JPA 1.0 with hibernate as my provider. Inside an entitymanager transaction, if a series of native queries are run (which include DELETE sql statements) and an error occurs, will the native queries rollback too on the error? I ran into a deadlock problem in an oracle database and I noticed that it left the database inconsistent...

Where to create a prepared statement with JDBC?

Consider to following method that read data from some data-structure (InteractionNetwork) and writes them to a table in an SQLite database using an SQLite-JDBC dirver: private void loadAnnotations(InteractionNetwork network) throws SQLException { PreparedStatement insertAnnotationsQuery = connection.prepareStatement( ...

Forcing a transaction to rollback on validation errors in Seam

Quick version: We're looking for a way to force a transaction to rollback when specific situations occur during the execution of a method on a backing bean but we'd like the rollback to happen without having to show the user a generic 500 error page. Instead, we'd like the user to see the form she just submitted and a FacesMessage that i...

DBTransaction Rollback throws

Looking into the documentation it says that the Rollback method can throw when the transaction is not in pending state (after begin transaction and before commit transaction). I can't seem to find a way to check whether the transaction can be rollback or not. There isn't a state property either. ...

Determining a transaction fee before an order is processed

When users make credit card transactions on my web app, I'd like to include the transaction fee on the confirmation page before the user makes the order. The thing is, there are different transaction fees for different cards. Is there a way to determine a transaction fee from the card number? I'm using Rails and ActiveMerchant, but I fi...

transactions in MS Access

Let's say I have the following code in a form that is triggered on some click event. DoCmd.SetWarnings False DoCmd.OpenQuery "AddSomeStuff" DoCmd.OpenQuery "UpdateSomeOtherStuff" DoCmd.OpenQuery "DeleteABunchOfCrap" DoCmd.SetWarnings True Can I assume that the three update queries I executed (in SQL Server) are not transactional in th...

Can I create a transaction using ADO NET Entity Data Model?

Hi is it possible on the following try-catch to execute a set of statements as a transaction using ADO NET Entity Data Model? [ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Customer c) { try { c.Created = DateTime.Now; c.Active = true; c.FullName = Request.Form["FirstN...

REST application, Transactions, Cache drop

Hi, I am building REST API in php with memcache layer on top for caching all resources. After some reading/experience it turns out it's best when documents are as simple as posible...mainly due to dropping cache sequences. So if there is 'building','room' entities for the 'room' document I would only place the id of the 'building' and...

Translate HTML files to another language

I have a website with Dutch text which I want to translate to English. Is there a fast way of doing this with keeping the HTML tags(<strong>,<span>) in tact. I know I can just copy the parsed TEXT into a translator but this will remove the formatting. I also know that at the end I have to go trough the text manually to fix some minor sp...

How can i attach data to a JTA transaction? (or uniquely identify it)

I have a getStockQuote() function that will get a current stock quote for a symbol from the stock market. My goal is that within a JTA transaction, the first call to getStockQuote() will fetch a stock quote, but all subsequent calls within the same transaction will reuse the same stock quote (e.g.: it will not try to fetch a new quote)....

What is the reason of "Transaction context in use by another session"

I'm looking for a description of the root of this error: "Transaction context in use by another session". I get it sometimes in one of my unittests so I can't provider repro code. But I wonder what is "by design" reason for the error. UPDATE: the error returns as SqlException from SQL Server 2008. A place where I get the error seems to...

Spring @Transactional method - participating transaction

in one dao I have 2 @Transactional methods. if i do not provide any explicit properties, then what will happen, if I run one method in the body of another? Both methods will run within THE SAME ONE TRANSACTION? ...