transactions

Pessimistic lock in T-SQL

故事扮演 提交于 2020-01-10 05:05:33
问题 If i SELECT a row for updating in MS SQL Server, and want to have it locked till i either update or cancel, which option is better :- 1) Use a query hint like UPDLOCK 2) Use REPEATABLE READ isolation level for the transaction 3) any other option. Thanks, Chak. 回答1: Neither. You almost never want to hold a transaction open while your user is inputting data. If you have to implement a pessimistic lock like this, people generally do it by rolling their own functionality. Consider the full

Spring-MVC : Creating a good infrastructure(configuration) and avoiding duplicates

主宰稳场 提交于 2020-01-10 04:40:08
问题 I am working on a Spring-MVC application since some time. Recently I ran into some problems with @Scheduled methods, and I noticed that the whole configuration is getting loaded 4 times. Because of that the @Scheduled methods are getting called 4 times. The 3 configurations which are not correct, die out with NullPointerException(is what I was told on SO), and the one survives. I am very much interested to know how can I configure my project properly, so there is only one configuration which

Why does Rails ignore a Rollback in a (pseudo)nested transaction?

孤者浪人 提交于 2020-01-09 10:00:43
问题 As per the docs ActiveRecord::Transactions::ClassMethods, a non-new nested transaction will ignore a Rollback. From the docs: User.transaction do User.create(username: 'Kotori') User.transaction do User.create(username: 'Nemu') raise ActiveRecord::Rollback end end The raise ActiveRecord::Rollback is ignored because it is in a child transaction (or rather, it is still within the parent transaction and not its own). I do not understand why the Rollback call would be ignored by both? I can see

What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”?

佐手、 提交于 2020-01-09 06:51:10
问题 What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”? I can not find it anywhere. Shall it be "Serializable"? 回答1: SaveChanges uses implementation of DbTransaction for current store provider. It means that default transaction isolation level is set to default value for the database server. In SQL Server it is READ COMMITTED . If you want to change isolation level you can use TransactionScope . You can also override SaveChanges in your derived

TransactionScope With Files In C# [duplicate]

☆樱花仙子☆ 提交于 2020-01-09 04:50:27
问题 This question already has answers here : How to write a transaction to cover Moving a file and Inserting record in database? (4 answers) Closed 2 years ago . I've been using TransactionScope to work with the database and it feels nice. What I'm looking for is the following: using(var scope=new TransactionScope()) { // Do something with a few files... scope.Complete(); } but obviously this doesn't work -- if there are 20 files, and an exception occurs on the 9th file, all previous 8 remain

Should I commit or rollback a read transaction?

我是研究僧i 提交于 2020-01-09 04:16:25
问题 I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do? Commit the transaction Rollback the transaction Do nothing (which will cause the transaction to be rolled back at the end of the using block) What are the implications of doing each? using (IDbConnection connection = ConnectionFactory.CreateConnection()) { using (IDbTransaction transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted)

Throwing an application exception causes TransactionalException

萝らか妹 提交于 2020-01-07 05:46:11
问题 I am implementing an JEE7 web application. During my work i have found a problem with handling my custom exceptions. I edited my account's property to have a non-unique login field. Then i invoked the AccountEditBean#editAccount() to run the editing process. When the process comes to AccountFacade#edit() i can see (in debug) that PersistenceException is caught and my custom NonUniqueException is thrown. The problem is, the exception is not propagated out of the facade class and it is not

Spring @Transactional TransactionRequiredException or RollbackException

一个人想着一个人 提交于 2020-01-07 02:47:26
问题 I have read a lot of @Transactional annotation, I saw stackoverflow answers but it does not help me. So I am creating my question. My case is to save user with unique email. In DB I have user with email xxx@xxx.com, and I am saving user with the same email address. For saving I have to use entityManager.merge() because of this post thymeleaf binding collections it is not important. First example: @Controller public class EmployeeController extends AbstractCrudController { // rest of code (...

Spring @Transactional configuring xml

三世轮回 提交于 2020-01-07 01:49:51
问题 The rollback in my transaction doesn't work (Spring 3.1). I tried to edit my configuration xml file, like here but without result. Here my xml file: <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop= "http://www.springframework.org/schema/aop" xmlns:tx= "http://www.springframework.org/schema/tx" xmlns:jpa="http:/

EJB Rollback does not work with Container Management Transaction or Bean Managament Transaction on commit exception

给你一囗甜甜゛ 提交于 2020-01-07 00:06:22
问题 I spent hours triying to do a rollback with EJB. I have a CDI controller where I want to remove some object. When I try to remove in EJB I get an exception and I Try to do rollback, but It does not work. Every SQL which has been execute with commit before get the exception does not rollback. Obviusly It is not because I get another exception when I try to do the rollback in BMT. Otherwise when I tried with CMT I get an exception of hibernate but I get the same results that BMT. My controller