Menu
  • HOME
  • TAGS

What is the better place to implement SQL Transaction? [closed]

c#,sql-server,transactions

My opinion first of all: in Stored Procedure. In SP very simple using transactions, example (MS SQL 2008R2) CREATE PROCEDURE P_MyProcedure AS BEGIN BEGIN TRANSACTION BEGIN TRY select 'Do someting here' END TRY BEGIN CATCH IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END END CATCH; IF @@TRANCOUNT > 0 COMMIT...

Should I use Blob storage or Azure VM storage for files?

transactions,asp.net-mvc-5,storage,windows-azure-storage,azure-virtual-machine

In this case, it seems you should create a separate container for the uploaded blobs and mark it public. Your app should save the user uploaded files to this public container. Then users can access the files from the container directly through the blob's URL. There are a few reasons...

EntityManager nested transaction atomicity

java,java-ee,jpa,transactions,eclipselink

JPA and JTA do not have support for nested transactions. When you need an overall transaction management system. Than use one. There are many possibilites. Spring is one of it or a JavaEE container managed system in an application server. You can also handle the whole operation on your own...

Fragment Transactions with transition - Unique transitionNames are required

android,transactions,fragment,transition,android-transitions

The problem is, that addSharedElement does NOT set the transaction name of the view! So in my example I would have to set it with following code: ViewCompat.setTransitionName(view.findViewById(R.id.ivLogo1), "1"); ViewCompat.setTransitionName(view.findViewById(R.id.ivLogo2), "2"); BEFORE I add this views to the FragmentTransaction... Afterwards following works just fine and as expected: ft.addSharedElement(view.findViewById(R.id.ivLogo1), "1"); ft.addSharedElement(view.findViewById(R.id.ivLogo2),...

How to force flushing in Grails GORM

grails,transactions,flush

You can get the session using the withSession method available in all domain classes and call to flush() on it. Operator.withSession { session -> // ... session.flush() } ...

Informix to PostgreSQL - Transaction Function

sql,postgresql,transactions,plpgsql,informix

After reading through your comments I finally managed to fix this one. Here is the PostgreSQL code that is working same as the Informix one I posted above: CREATE OR REPLACE FUNCTION buyTicket(pFlightId INT, pAmount INT) RETURNS VOID AS $$ BEGIN INSERT INTO transaction(flightId,amount) VALUES (pFlightId, pAmount); UPDATE tickets SET...

hibernate rollback not working in service layer

hibernate,postgresql,transactions,junit4,spring-4

Using REQUIRES_NEW will run your code in a new transaction separately from the one that JUnit creates. So you are creating a nested transaction by invoking your service layer code. Change Propagation.REQUIRES_NEW to Propagation.REQUIRED in your service layer. Also since Propagation.REQUIRED is the default propagation level, you can remove this...

What is the right way to use multiple savepoints

sql,sql-server,transactions,savepoints

SAVE TRAN requires transaction count > 0, thus you must have committed your transaction in the previous CATCH block. You have several options: 1) Replace your SAVE TRAN statement with the following (you can use the same savepoint name, however a rollback will rollback only to the last savepoint): IF...

Laravel: what happens if I have separate read/write connections configured, and do both reads and writes within a transaction?

php,laravel,laravel-4,transactions,laravel-5

If you're saying you want to do both reads and writes within a transaction using the same connection, then that will work fine - you can read from the database during the transaction. If you're saying you want to read using one connection while you're writing as part of a...

Is spring transaction is only working in entering service method?

mysql,spring,transactions,spring-transactions

spring @Transactional works using proxies, that means that calling method with this annotation from same class does not have any influence == @Transactional is going to be ignored. There are maaaaany topics about it, please take a look at deeper explanation for example here: Spring @Transaction method call by the...

ServiceStack OrmLite and transactions

sql-server,transactions,ormlite-servicestack

Someone else put this answer in a comment and then deleted it... so: BeginTransaction needs to be OpenTransaction...

Why does my Jboss server begin transactions for everything and anything?

transactions,jboss7.x,jta

Is this the expected behavior? Well, no. At least not as far as Java EE, JSF and EJBs are concerned. So there's that. But the project (and enough of the pom file of the new test project I used to try and triangulate the problem) is a bastard of...

Transactions and Eloquent

php,laravel,transactions,eloquent,laravel-5

$user isn't in scope inside your callback $user = $this->auth->user(); DB::transaction(function() use ($user) { $stores_amount = $user->stores()->count(); }); EDIT $stores_amount is only scoped inside of the callback. If you need to get the $stores_amount value out of the transaction, then you can declare it and scope it into the callback...

SQL Azure Connection and Transaction

transactions,sql-azure,saas

No, multi-statement transactions are opened explicitly. I believe there are some esoteric settings you can use to open one implicitly but I consider those to be severe design mistakes and evil. I don't understand why you want this behavior. Rather, open a transaction explicitly. There is no behavioral difference caused...

Insert transaction if not exists in SQL Server

sql,sql-server,insert,transactions,procedures

if you planing to use stored procedure you can create stored procedure: CREATE PROCEDURE spAddTrack @trackName VARCHAR(MAX) AS If not exists( Select * from [s15guest59].[dbo].[track] where [email protected]) BEGIN INSERT INTO [s15guest59].[dbo].[track](track_topic) VALUES (@trackName) END thank execute it with: EXEC spAddTrack 'this is new track' ...

Transactional annotation does not save on exit

spring,hibernate,jpa,transactions

If you have both a ContextLoaderListener and DispatcherServlet they both load a configuration file. Judging from your configuration the services are loaded by the DispatcherServlet and your <tx:annotation-driven /> is loaded by the ContextLoaderListener. They both create an ApplicationContext and as AOP is only applied to the beans in the...

SimpleMessageListenerContainer ChannelTransacted and MaxConcurrentConsumers

transactions,rabbitmq,amqp,spring-amqp

It's a bug - please open a JIRA issue. There is not a workaround, unfortunately; it needs a patch. The use of transactions with RabbitMQ is quite rare, especially on the consumer side - can you explain why you need them?...

Spring JPA transaction in clustered environment

spring,jpa,transactions,cluster-computing,jta

The transaction isolation behaviour and limitations are dependent on the database provider. Now if your using Oracle RAC , I haven't seen issues but on a MYSQL instance this is an issue.

Manage rollback on transaction in my managed bean

java,spring,hibernate,transactions,rollback

Transactions should be managed on the service layer, not data access. Example from spring: @Transactional(readOnly = true) public class DefaultFooService implements FooService { public Foo getFoo(String fooName) { // do something } // these settings have precedence for this method @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void updateFoo(Foo foo)...

How to differentiate change transaction from actual transaction in bitcoin raw transaction template?

transactions,rpc,bitcoin

It seems that there is no good answer to this question, I found a duplicate on stackexchange: http://bitcoin.stackexchange.com/questions/28182/how-to-find-the-change-sender-address-given-a-txid tl;dr: anything you will do to guess which public address is the sender's/receiver's (based on the amounts of both inputs and outputs) will stay a guess because the bitcoin core want to...

Hibernate : Stale state exception

java,spring,hibernate,spring-mvc,transactions

The reason for the exception is that you were loading a GroupCanvas before and this has a reference to the GroupSection. Then you delete the GroupSection but when the transaction commits GroupCanvas still holds a reference to the deleted GroupSection and you get the StaleStateException. As you saw, deleting the...

Trying to understand why @transactional(noROllBackFor … is not working

java,spring,jpa,transactions

After reading the answers on my original post I switched to using Spring Retry and was able to remove all my looping code. The method now looks like this: @Transactional @ConcurrentDBUpdateRetryPolicy public void deleteSomeData() { this.myDAO.deleteTheData(); } With a custom annotation which defines the retry policy I want to employ....

Spring and JPA/Hibernate how to increment a counter without concurrency issues

java,spring,hibernate,jpa,transactions

The simplest solution is to delegate the concurrency to your database and simply rely on the database isolation level lock on the currently modified rows: The increment is as simple as this: UPDATE Tag t set t.count = t.count + 1 WHERE t.id = :id; and the decrement query is:...

JPA difference between transaction isolation and entity locking

java,database,jpa,concurrency,transactions

Introduction There are different locking types and isolation levels. Some of the locking types (OPTIMISTIC*) are implemented on the JPA-level (eg. in EclipseLink or Hibernate), and other (PESSIMISTIC*) are delegated by the JPA-provider to the DB level. Explanation Isolation levels and locking are not the same, but they may intersect...

SQLite3 — Return Affected Rows

jdbc,sqlite3,transactions

The best way to do something in a transactional manner is with a transaction: BEGIN; SELECT ID, Name FROM MyTable WHERE IntValue = 1 ORDER BY Random() LIMIT 1; UPDATE MyTable SET IntValue = 0 WHERE ID = ?; COMMIT; ...

SSIS 2012 Transaction in ForEach Loop

ssis,transactions,ssis-2012,foreach-loop-container

Change the maximum error count of the Loop container and all parent containers to 3, and changed the "stop package on failure" flag to false. This should allow it to continue looping. While this should work, I don't advocate this approach. I would split the three transactions into separate containers,...

Auto-COmmit of DDL

mysql,transactions,persistence,rdbms,ddl

Executing a DDL statement causes an "implicit commit". But the statement has to be executed. The scenario you give doesn't make sense to me, the createStatement method doesn't take a string as an argument, does it? We typically see stmt = conn.createStatement(); stmt.execute("CREATE TABLE ... "); If you actually execute...

What to do if Cassandra reports failure but did a partial write?

transactions,cassandra,acid

In cassandra a timeout such as this is not considered a failure. See this blog post describing how Cassandra handles different conditions when it comes to writes: Remember that for writes, a timeout is not a failure. How can we say that since we don’t know what happened before the...

SQLite multithread - avoid unnecessary blocking for readers

php,multithreading,sqlite,transactions

A deadlock can happen when two transactions want to upgrade their read locks to write locks. To guarantee that this cannot happen, at least one of those transactions must use BEGIN IMMEDIATE. Read-only transactions are not involved with such deadlocks (they always end without needing more locks), so they can...

What does the exclusive lock on storage for OrientDB entail exactly?

concurrency,transactions,locking,orient-db

In current release of OrientDB, transactions lock the storage in exclusive mode. Fortunately OrientDB works in optimistic way and this is done "only" at commit() time. So no matter when the transaction is begun. If this is a showstopper for your use case, you could consider to: don't use transactions....

Why does MVCC require locking for DML statements

postgresql,transactions,locking,dml,mvcc

The answer to the first question is Yes. No DBMS can support dirty writes; if two transactions T1 and T2 are concurrently executing and T2 overwrites an update from T1, then the system cannot handle the case where T1 subsequently issues a ROLLBACK since T2's update has already occurred. To...

PDO Transaction with Prepared Statements not working

php,mysql,pdo,transactions,prepared-statement

Each transaction should begin with beginTransaction() and end with commit() You can commit the transaction just after you execute the last query: $stmt->execute(); $conn->commit(); ...

App Engine: Mechanics of creating a unique entity if it doesn't exist

google-app-engine,transactions,gae-datastore

To answer your question we must dig deeper, into the source code of the dev datastore, fortunately for us it is very well documented, just take a look at LiveTxn._GrabSnapshot: Gets snapshot for this reference, creating it if necessary. If no snapshot has been set for reference's entity group, a...

Spring @Transactional how to “stop” transaction

java,spring,transactions,transactional

You need to have a transaction for the two first steps, then have the transaction committed, and finally send the email. The easiest way to do that is to introduce an additional bean Controller: beanA.process(); Bean A: // not transactional public void process() { beanB.updateDatabase(); sendEmail(); } private void sendEmail()...

Can Cassandra LWTs have an IF part in terms of a PRIMARY KEY

java,transactions,cassandra,datastax-java-driver

You can't set a condition on a partition key column (IF name = 'foo'), because that column is already restricted in the where clause (WHERE name = 'foo'). There is indeed a problem with the error message. This has apparently been fixed, with Cassandra 2.1.4 I get: PRIMARY KEY column...

Transactions in php function or in mysql stored procedure?

php,mysql,pdo,transactions

It depends on what you're trying to achieve. If you want to see all the inserts as an 'atomic operation' you are doing right, as if one call to the SP fails, the rollback will undo all the changes made from the previous calls If, otherwise, you want to "isolate"...

Atomic increment of counter column using simple update

sql,transactions,sql-update,atomic

If you only ever use it as simple as this, you're fine. The problems start when: You add a condition - most conditions are fine, but avoid filtering based on Counter, that's a great way to lose determinism You update inside of a transaction (careful about this - it's easy...

Prevent previously loaded entity being updated in transactional method

java,spring,transactions

Use EntityManager.detach(), to detach the entity from the persistence context: User oldUser = userService.findUserById(userId); if (oldUser.infoIsTheSame(userInfo)) { return; } em.detach(oldUser); User updatedUser = userService.addUserInfo(userId, userInfo); feedService.addFeed(FeedAction.INFO_UPDATE, oldUser, updatedUser); ...

Calling Fragment from inside the BaseAdapter class in PageViewer Android

android,android-fragments,tabs,transactions,android-viewpager

Use this: Fragment.replace("res_id",fragement to replace); ...

Rails on create transaction

ruby-on-rails,devise,transactions

I've done some research into your question and using after_create seems to be ok as long as an exception is raised if it fails. That will rollback the transaction as well. Just use the default callbacks. Here is a good answer related to the question....

The type or namespace name 'Transactions' does not exist in the namespace 'System'

c#,asp.net,.net,visual-studio-2013,transactions

Refer to this Answer By Mark Hall There is a Microsoft Connect entry posted for this. There is a comment that suggests that you can browse for it. The path given is: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Transactions.dll Just Add reference by browsing to this path if this did not work, Go...

How to set up 2 IBDatabase to 1 IBTransaction?

delphi,transactions,database-connection

This may occur if you started transaction explicitly. Every explicit transactions must be finished explicitly. So, if your connection is open explicitly, you should close it explicitly. You may use : //Commit(Stop) the transaction before open an other connection if Dm.Transaction.InTransaction then dm.Transaction.Commit; Note: In applications that connect an InterBaseExpress...

Spring JavaFX @Transactional entitymanager is closed

spring,exception,javafx,transactions,transactional

By reading logs, i've understood what's happened. A thread was closing the applicationContext, and implicitely all singletons beans including the entityManagerFactory ! The entityManagerFactory can only be open once per PersistenceUnit lifecycle. When the Transaction try to open an entityManager with a closed factory, it throw an exception....

How to delete previous table transaction if next table transaction fails

c#,sql,asp.net,sql-server,transactions

Wrap the entire block in a SqlTransaction, and don't open/close your connection for each statement: conn.Open(); using(SqlTransaction tran = conn.BeginTransaction("Adjustment")) { SqlCommand sqlcmd1 = new SqlCommand("INSERT INTO adjustment_header values('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"')",conn, tran); sqlcmd1.ExecuteNonQuery(); //adjustment grid row 1 if (itemno1.SelectedItem.Text != "please select") { SqlCommand cmd1 = new SqlCommand("INSERT INTO adjustment_grid values('"+TextBox1.Text+"','" +...

Grails: Store audit record regardless of success/failure?

hibernate,grails,transactions,audit

In our application, we use the Platform Core plugin for this. Basically, when some interesting things happen, such as: User logs in New user signs up User creates a new instance of some business object User deletes something etc... We fire an event, like this: event( 'myApp.activity', [ userId: userService.currentUser?.id,...

Runtime exception is @ApplicationException(rollback=false) but transaction is finally rolled back

java,java-ee,transactions,ejb

Per section 7.1 of the EJB 3.2 specification: It is illegal to associate JTA transactional interceptors (see [8]) with Enterprise JavaBeans. The EJB Container should fail deployment of such applications.[39] [39] This restriction may be removed in a future release of this specification. Since the @Transactional annotation is incorrectly being...

Transaction with binded thread connection in Spring

spring,jdbc,transactions,spring-transactions

You are trying to reimplement the things that are already implemented by the transaction abstraction of Spring. Simply use the proper PlatformTransactionManager (you can probably grab that from an ApplicationContext) keep a reference to the TransactionStatus instead of a DataSource and use that to commit/rollback. public TransactionStatus initTransaction() { return...

PHP/MySQL Critical section

php,mysql,transactions,innodb,critical-section

The code is fine, with one exception: Add FOR UPDATE to the initial SELECT. That should suffice to block the second button press until the first DELETE has happened, thereby leading to the second one "failing". https://dev.mysql.com/doc/refman/5.5/en/innodb-locking-reads.html Note Locking of rows for update using SELECT FOR UPDATE only applies when...

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

java,spring,hibernate,spring-mvc,transactions

There are a lot of things that can be improved with your code and configuration. Lets start with your dao, don't store the Session in a instance variable and I strongly suggest to use constructor injection for the required dependencies. Taking this into account your dao(s) should look something like...

Get current database transaction id using jdbc/hibernate?

java,mysql,hibernate,jdbc,transactions

With PostgreSQL, you could simply run this native query to get the current transaction id: Number transactionId = (Number) session .createSQLQuery("select txid_current()") .uniqueResult(); For MySQL, you need to run 5.7 or later: Number transactionId = (Number) session .createSQLQuery( "SELECT GTID " + "FROM events_transactions_current e " + "JOIN performance_schema.threads t...

Trigger to cancel transaction

sql,oracle,triggers,oracle11g,transactions

You can see the database state after the statement using an "after statement" trigger (i.e. leaving out the for each row clause). However you do not have access to old and new in a statement-level trigger. You can either check that no data in the 4 tables breaks your rules...

Mysql Transaction: Effect on other Transaction query

php,mysql,sql,database-design,transactions

With code like this, there is no race condition. Instead, one transaction could be aborted (ROLLBACK'd). BEGIN; SELECT balance FROM Accounts WHERE acct_id = 123 FOR UPDATE; if balance < 100, then ROLLBACK and exit with "insufficient funds" UPDATE Accounts SET balance = balance - 100 WHERE acct_id = 123;...

Can LINQ BeginTransaction works with new Context?

c#,linq,entity-framework,transactions

You have three options here. First, you can configure Ninject to use the same instance of DbContext for both your PersonController and your PersonRepository. You do this by configuring your binding to use InRequestScope(). Then, you can call BeginTransaction and it's the same context. Alternatively, you could just add BeginTransaction,...

Connection Pool Empty Hibernate 4, but Unable to Find the Culprit

hibernate,tomcat,transactions,sql-server-2012,connection-pooling

I want to first thank everyone for contributing your answers. Like @JensSchauder had suggested I was working on trying to isolate the problem. Wondering why I didn't have the problem in QA, but did so in production. Even though I followed up with my Network Operations team, no one hit...

Spring Transaction Isolation Level

java,mysql,spring,hibernate,transactions

Read-only allows certain optimizations like disabling dirty checking and you should totally use it when you don't plan on changing an entity. Each isolation level defines how much locking a database has to impose for ensuring the data anomaly prevention. Most database use MVCC (Oracle, PostgreSQL, MySQL) so readers don't...

In Django, how to achieve repeatable reads for a transaction?

python,django,transactions,isolation-level,transaction-isolation

You're right, default transaction isolation level in postgres is READ COMMITTED. You can easily change it in settings to test whether it would fit your needs: https://docs.djangoproject.com/en/1.8/ref/databases/#isolation-level Also I doubt you will face some performance issues because postgres operates very efficiently while working with transactions. Even in SERIALIZABLE mode. Also...

Spring Hibernate “You cannot commit during a managed transaction!”

java,spring,hibernate,transactions,jboss7.x

You probably configured a JTA DataSource in JBoss, which is a managed transactional resource and then you are using a non-JTA HibernateTransactionManager. To fix it, you have two options: You either use a RESOURCE_LOCAL DataSource and provide it via JNDI You keep the JTA DataSource and configure Hibernate to use...

Process REST request to retrieve data via Hibernate in a separate Thread

java,multithreading,spring,hibernate,transactions

The HibernateTemplate should allow you to create a new Hibernate Session because the current SpringSessionContext ThreadLocal storage has no Session bound. Related to the design, you should close the ScrollableResults and release the database related resources (connection, cursor). I would therefore design it like this: The initial request builds a...

Integration Tests for WebAPI and transactions

rest,asp.net-web-api,transactions

Unfortunately the current options are not ideal, here is what I have set-up on a relatively large project - which is not far away from the official testing guide over here . This all relies on automation of your build/test/deploy processes (i.e. ALM- application life-cycle management, we use Visual Studio...

Multiple transaction managers - Selecting a one at runtime - Spring

java,spring,transactions,spring-transactions

I think you need a Facade. Define an interface and create 2 classes implementing the same interface but with different @Transactional(value = "qatxManager") Then define one Facade class which keeps 2 implementations (use @Qualifier to distinguish them) The Facade gets the env String and call method of proper bean...

Communication to caller of method annotated @Transactional

java,spring,transactions

The method calling your persistence layer will catch any RuntimeExceptions, and that will let it know that you had an error while persisting the data. Spring by default rolls back any transaction that throws a RuntimeException. Here is an abbreviated example of what I mean. AmendementService @Service public class AmendmentService...

Why does dropping a table not work with SQLServer unless a Transaction is used?

java,sql-server,transactions

Unlike Oracle and MySQL, SQL Server supports transactional DDL. That means you have to commit DDL statements - unless your connection is configured to use auto-commit. Transactional DDL is a very nice feature because it allows for "all-or-nothing" migration scripts. A rollback will also rollback a drop table! Transactional DDL...

Spring transaction management

java,spring,hibernate,spring-mvc,transactions

In my opinion, you can achieve this with minimal change on the current application by following what Spring does in its org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(Object, TransactionDefinition). In detail, I think something like following should work: On the GenericAction, get connection from data source (as you've already done) Bind the connection via its holder...

Ensure concurrent (money) transactions in Entity Framework?

c#,mysql,entity-framework,transactions,atomic

You can use sql transactions with repeatable read isolation level instead of locking on the application. For example you can write public long ChangeScoreAmount(int userID, long amount) { using(var ts = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead }) { var profile = this.Entities.account_profile.First(q => q.AccountID == userID); profile.Score...

Google Datastore app architecture questions

google-app-engine,transactions,google-datastore

No, ('Country', 123123) and ('Country', 679621) are not in the same entity group. But ('Country', 123123, 'City', '1') and ('Country', 123123, 'City', '2') are in the same entity group. Entities with the same ancestor are in the same group. Sounds like really bad idea to use auto-increment for things...

Get all transactions on monday between 10 and 11am

django,datetime,django-models,transactions

Use the week_day and hour lookups: P1data.objects.filter(date_time__week_day=2, date_time__hour__range=(10, 11)) UPDATE: If hour lookup doesn't support range then try to use the combination of lte/gte: P1data.objects.filter(date_time__week_day=2, date_time__hour__gte=10, date_time__hour__lte=11) ...

C# MySQL Transaction commit

c#,mysql,transactions

You should not use single quotes with your parameters. With single quotes, your query see them as a string literal, not a parameter. cmd.CommandText = "UPDATE products SET [email protected], [email protected] WHERE itemId LIKE @itemId"; Also since you try to parameterize LIKE part, you need to use %..% part in your...

Integrity while reading from two tables: orders and order_items

database,postgresql,transactions

You'll need to fetch a nice hot cup of tea and coffee and read the page on transaction isolation. There are two options. In the first case, assume you lock the tables to prevent writes.Then, so long as B is doing the updatesin a single transaction then "read committed" will...

PHP: Is there a relationship between PDO transactions and Sessions?

php,yii,pdo,transactions,session-variables

Session is written to the database at the end of the request. If you make an explicit rollback, it still gets written to the db outside of the transaction. If you don't, the rollback happens implicitly AFTER the session saving queries are run.

Codeigniter: Loop in start_transaction

php,codeigniter,activerecord,transactions

It won't effect anything. Suppose your loop has started say from 1 and now reached at position say 15 so the id's inserted in the table would be 1-15 and now some other person added another row and the id moves ahead to 16 and now your continuous loop will...

How to restore transaction in android in-app purchase version 3 application?

android,ios,transactions,in-app-purchase,in-app-billing

I found answer my self i.e if my product is managed product that will be handled by google, managed means if it once purchased then it is purchased for that account(like gmail account), so if user is uninstalls it and again install then that product is purchased(based on account Id)....

What data is stored in transaction?

database,spring,data,transactions,transactional

Its not about stored data in transaction. Its about running some operations in one transaction. Imagine that you create banking system, and you have method for making money transfer. Lets assume that u want to transfer amount of money from accountA to accountB You can try sth like that in...

Why does not “@Transactional(propagation = propagation.NEVER)” work?

java,spring,transactions,spring-aop,spring-annotations

@Transactional annotations only apply to the Spring proxy objects. For example, if you call allProcessOnDB_second() from some spring bean which injects your service like this @Autowired private MyService myService; ... myService.allProcessOnDB_second(); then myService is Spring proxy, and its @Transactional(propagation = Propagation.REQUIRED) is applied. If you were to call myService.getDeps(id) then...

How can I add FOR UPDATE to a cakephp3 query?

select,transactions,sql-update,cakephp-3.0,isolation-level

You can do it with Query::epilog() $selectQuery->...->epilog('FOR UPDATE'); ...

Camel consume single message and stop, transacted

java,transactions,apache-camel,consumer,once

I ended up using the pollEnrich dsl to achieve this. For example my route builder looks like: from("direct:service-endpont").transacted("PROPOGATION_REQUIRED").setExchangePattern(ExchangePattern.InOut).pollEnrich("activemq:test-queue").bean(myHandler); I use the direct endpoint as a service, sending a "request" message to the direct endpoint polls the jms queue for a single message (blocking if required). The transaction started extends to...

The insert , update and delete et command are default work with Transactions in Mysql?

mysql,transactions

Please check autocommit is true/ false. If autocommit=1 then it will insert record automatically. Set autocommit false in your setting SET autocommit=0; Please refer following link Mysql transaction...

Downside of using transaction dispose with entity framework integration testing

entity-framework,transactions,entity-framework-6.1

as the database is never touched Surely it's touched. Everything that happens within the transaction happens in the database. Identity values and sequences (if any) are incremented, triggers fire, referential constraints are checked, etc. etc. The only thing is, it happens in isolation and in the end everything (except...

Django transactions: managing two different transactions atomically inside the overriding of save() method

python,django,transactions

As suggested by Gocht in the comments under the question, a solution in Django 1.4 is using @transaction.commit_on_success(). The code could be something like this: from django.db import models from django.db import transaction class MyModel(models.Model): # model definition @transaction.commit_on_success() def save(self, *args, **kwargs): try: super(MyModel, self).save(*args, **kwargs) do_other_things() obj2 =...

Build array of objects from params hash after Transaction block fails, Rails

ruby-on-rails,ruby,transactions

Ok, so you're trying to iterate through a list of objects in your params using a for_each and an external iterator, you really don't want to do that. I'd suggest something like this: params[:users].each do |k,v| # k is the "key" of each user while v is the values associated...

Create Spring @Service instance with @Transactional methods manually from Java

java,spring,transactions,aop,spring-aop

HIbernate has out of the box support for multi tenancy, check that out before trying your own. Hibernate requires a MultiTenantConnectionProvider and CurrentTenantIdentifierResolver for which there are default implementations out of the box but you can always write your own implementation. If it is only a schema change it is...

Spring @Transactional on @Bean declaration instead of class Implementation

java,spring,jpa,transactions

Found something built-in that is the sum of @Mecon's and @Erik Gillespie's answers, with limited boilerplate. Spring already provides a TransactionProxyFactoryBean that just sets up a transactional proxy on any object. Much of the setup could be refactored to some utility method : @Configuration @EnableTransactionManagement public class ComplexComponentConfig { /**...

Sequelize - Inserting multiple associated entities in transaction fails

transactions,associations,sequelize.js

I tried the latest sequelize tag (not release) which was 2.1.0 at that time, as suggested by Jan, it works just fine but I only had to use Promise.map with {concurrency:1} instead of Promise.all since tedious (I am on a MS SQL Server DB) was complaining about executing two queries...

ORMLite + Transactions

transactions,ormlite

The transaction should be limited to a single connection (the localConnection). How does the DAO handle that? Or does it not handle it at all? Hrm. I'm not 100% sure why the connection method is exposed. I'm going to deprecate it. You really should be using the dao.callBatchTasks(...) method....

Fewer Columns In INSERT Statement Than In Values Clause

sql-server,insert,transactions,identity

You have double comma between tin and presentAddress: sss + "','" + tin + "','" + "','" + presentAddress ...

Do I need to annotate JPA actions with @Transactional in Play Framework-1.x to prevent the connection leak?

jpa,transactions,playframework-1.x,transactionmanager

I used this approach where there are calls to different entity managers: @Transactional public static void someAction() { ... EntityManager entityManagerOne = JPA.em("NameOfEntityManagerOneHere"); try { Query query = entityManagerOne.createQuery(...); ... // other actions with entityManagerOne (before closing) } finally { entityManagerOne.close(); } EntityManager entityManagerTwo = JPA.em("NameOfEntityManagerTwoHere"); try { Query query...

SQL Server Rolls back my transaction when using THROW

sql-server,transactions,throw

THROW will terminate the batch when outside the scope of TRY/CATCH (https://msdn.microsoft.com/en-us/library/ee677615.aspx). The implication here is that no further processing of the batch takes place, including the statements following the insert. You'll need to either surround your INSERT with a TRY/CATCH or use RAISERROR instead of THROW. T-SQL error handing...

Why my mysql transaction is not working properly?

php,mysql,mysqli,transactions,database-connection

You can only do one query at a time with mysqli_query Look at mysqli_multi_query() http://www.w3schools.com/php/func_mysqli_multi_query.asp $query= "START TRANSACTION; INSERT INTO `123`.`table1` (`name1`,`name2`) VALUES ('". $name . "','". $email ."'); INSERT INTO `123`.`table2` (`table1_id`,`name3`,`name4`) VALUES (LAST_INSERT_ID(),'". $story . "','". $img ."'); COMMIT;"; var_dump(mysqli_multi_query($con,$query)); ...

Can RPUSH and LPUSH in Redis race?

transactions,redis,race-condition

Since Redis is single threaded, there is no such thing as them happening at the "same time", one will always arrive ahead of the other, though the timing is often beyond your control. Now if you have two processes can be coordinated in some way you can have one defer...

I'm puzzling in hibernate and mysql when commit the transaction

java,spring,hibernate,transactions

Of course, if I use session.flush(),it can commit to the database,but I think it is not a good way, because it cannot ensure the consistent of the transaction. The fact that you state everything works if you call flush() is strange as flush() != commit(). By calling flush() all...

Wildfly - Infinispan Transactions configuration

java,transactions,ejb,wildfly,infinispan

When using NON_XA transactions, failure to commit TX in cache may let the transaction to commit, and you would not get any exception that would tell you that the cache is inconsistent. As for cache.values(), prior to Infinispan 7.0 it returns only local entries, however that should not matter in...