transactions

Grails - DuplicateKeyException

狂风中的少年 提交于 2020-01-15 12:47:30
问题 I have got the following piece of code which adds new object to database. Firstly it takes another object from DB and add to the final object. Few lines of my code ClassC c = ClassC.findByName(cName) ClassD d = new ClassD( name: "WHATEVER", classC: c ) print "AAA\n" ClassC.withTransaction { c = c.merge() // c.save(failOnError: true, flush: true) } print "BBB\n" // ClassD.withTransaction { // d = d.merge() // } // print "CCC\n" ClassD.withTransaction { d.save(failOnError: true, flush: true) }

DynamoDb. Conditional write on Create. Check by the filed if NotEqual (NE)

China☆狼群 提交于 2020-01-15 10:12:48
问题 Say, I want to save/create new item to the DynamoDb table, if and only if there is not any existent item already that that would contain the referenceId equal to the same value I set. In my case I want to create a item with withReferenceId=123 if there is not any other withReferenceId=123 in the table. the referenceId is not primary key! (I don not want it to be it) So the code: val withReferenceIdValue = "123"; val saveExpression = new DynamoDBSaveExpression(); final Map<String,

DynamoDb. Conditional write on Create. Check by the filed if NotEqual (NE)

淺唱寂寞╮ 提交于 2020-01-15 10:12:31
问题 Say, I want to save/create new item to the DynamoDb table, if and only if there is not any existent item already that that would contain the referenceId equal to the same value I set. In my case I want to create a item with withReferenceId=123 if there is not any other withReferenceId=123 in the table. the referenceId is not primary key! (I don not want it to be it) So the code: val withReferenceIdValue = "123"; val saveExpression = new DynamoDBSaveExpression(); final Map<String,

Grails Service Transactions

一个人想着一个人 提交于 2020-01-15 09:51:49
问题 I'm trying to get transactions working within a Grails service, but I'm not getting the results I'm expecting. Can someone tell me if I'm doing something wrong, if my assumptions are off? My domain class: class Account { static constraints = { balance(min: 0.00) } String companyName BigDecimal balance = 0.00 Boolean active = true String toString() { return "${companyName} : ${balance}" } } My service: class AccountService { static transactional = true def transfer(Account source, Account

Grails Service Transactions

回眸只為那壹抹淺笑 提交于 2020-01-15 09:51:31
问题 I'm trying to get transactions working within a Grails service, but I'm not getting the results I'm expecting. Can someone tell me if I'm doing something wrong, if my assumptions are off? My domain class: class Account { static constraints = { balance(min: 0.00) } String companyName BigDecimal balance = 0.00 Boolean active = true String toString() { return "${companyName} : ${balance}" } } My service: class AccountService { static transactional = true def transfer(Account source, Account

Sails.js + Postgres: issue with transactions

元气小坏坏 提交于 2020-01-15 05:43:53
问题 I am trying to implement a transaction in Sails 0.10.5 using Postgres as database, but the operations are not committed (or rolled back) at the end. This is a simple transaction scenario I wrote down as a test (using async.js): testTransaction: function(uri) { var testFile = { uri: uri, details: { 'firstDetail': 'value' } }; async.auto({ begin_transaction: function(callback) { DataFile.query('BEGIN TRANSACTION;', callback); }, new_data_file: ['begin_transaction', function(callback) { DataFile

Spring Isolation Support? MSQL Snapshot Isolation

大憨熊 提交于 2020-01-14 20:07:31
问题 We are using SQL Server and it is possible that Snapshot isolation may be a good way to improve out performance and fix some deadlocking concerns. Assuming that we have a real need to change to Snapshot isolation, I can't seem to find an easy way to enable Snapshot isolation on Springs @Transactional . I found the following hibernate configuration option for doing it in Hibernate, however we use spring-jdbc and don't have a hibernate impl. this seems to suggest that the isolation value could

MySQL InnoDB deadlock problem with two same queries (different parameters)

元气小坏坏 提交于 2020-01-14 17:51:20
问题 I have the following table CREATE TABLE IF NOT EXISTS `task` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `job_id` int(10) unsigned NOT NULL COMMENT 'The id of the related job', `server_id` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'job/task owner', `jobtype_id` int(10) unsigned NOT NULL DEFAULT '0', `node_id` int(10) unsigned NOT NULL COMMENT 'The id of the user currently executing this task', `status` enum('QUEUED','EXECUTING','COMPLETED','CANCELED','TERMINATED','PAUSED','FAILED') NOT

Transactions in MySQL - Unable to Roll Back

删除回忆录丶 提交于 2020-01-14 09:01:37
问题 I'm using MySQL 5.0.27 and am trying to get transactions to work. I followed this tutorial: http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqltransaction.html and still cannot get these to work. The table I am trying to update is InnoDB and have tried to execute 'set autocommit=0' but it doesn't seem to be doing anything.... The code I've written is the following: public int transactionUpdate() { MySqlConnection connection = new MySqlConnection(connStr); connection.Open();

Can I use transactions with ALTER TABLE?

我只是一个虾纸丫 提交于 2020-01-14 07:59:07
问题 I'm a beginner (actually complete newbie) to SQL transactions, so I may be missing something obvious. I have this SQL code, that I'm trying to run through phpMyAdmin : START TRANSACTION; INSERT INTO `users` VALUES(NULL, 'User A', 'user.a@example.com', '4', 'User A'); INSERT INTO `users` VALUES(NULL, 'User B', 'user.b@example.com', '3', 'User B'); ALTER TABLE `users` CHANGE `level` `level` TINYINT(3) UNSIGNED NOT NULL; ALTER TABLE `users` CHANGE `number` `number` INT(10) UNSIGNED NOT NULL;