javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

I don’t understand what is the actual difference between annotations javax.transaction.Transactional and org.springframework.transaction.annotation.Transactional? Is org.springframework.transaction.annotation.Transactional an extension of javax.transaction.Transactional or they have totally different meaning? When should each of them be used? Spring @Transactinal in service layer and javax in DAO? Thanks for answering. 4 Answers 4

What is the difference between Non-Repeatable Read and Phantom Read?

What is the difference between non-repeatable read and phantom read? I have read the Isolation (database systems) article from Wikipedia, but I have a few doubts. In the below example, what will happen: the non-repeatable read and phantom read? Transaction A SELECT ID, USERNAME, accountno, amount FROM USERS WHERE ID=1 OUTPUT: 1—-MIKE——29019892———5000 Transaction B UPDATE … Read more

SQL Server – transactions roll back on error?

We have client app that is running some SQL on a SQL Server 2005 such as the following: BEGIN TRAN; INSERT INTO myTable (myColumns …) VALUES (myValues …); INSERT INTO myTable (myColumns …) VALUES (myValues …); INSERT INTO myTable (myColumns …) VALUES (myValues …); COMMIT TRAN; It is sent by one long string command. If … Read more

Does Spring @Transactional attribute work on a private method?

If I have a @Transactional -annotation on a private method in a Spring bean, does the annotation have any effect? If the @Transactional annotation is on a public method, it works and open a transaction. public class Bean { public void doStuff() { doPrivateStuff(); } @Transactional private void doPrivateStuff() { } } … Bean bean … Read more

Correct use of transactions in SQL Server

I have 2 commands and need both of them executed correctly or none of them executed. So I think I need a transaction, but I don’t know how to use it correctly. What’s the problem with the following script? BEGIN TRANSACTION [Tran1] INSERT INTO [Test].[dbo].[T1] ([Title], [AVG]) VALUES (‘Tidd130’, 130), (‘Tidd230’, 230) UPDATE [Test].[dbo].[T1] SET … Read more

TransactionScope automatically escalating to MSDTC on some machines?

In our project we’re using TransactionScope’s to ensure our data access layer performs it’s actions in a transaction. We’re aiming to not require the MSDTC service to be enabled on our end-user’s machines. Trouble is, on half of our developers machines, we can run with MSDTC disabled. The other half must have it enabled or … Read more

Using Transactions or SaveChanges(false) and AcceptAllChanges()?

I have been investigating transactions and it appears that they take care of themselves in EF as long as I pass false to SaveChanges() and then call AcceptAllChanges() if there are no errors: SaveChanges(false); // … AcceptAllChanges(); What if something goes bad? don’t I have to rollback or, as soon as my method goes out … Read more