FAQ Database Discussion Community


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

java,spring,transactions,aop,spring-aop
Let's say there are @Service and @Repository interfaces like the following: @Repository public interface OrderDao extends JpaRepository<Order, Integer> { } public interface OrderService { void saveOrder(Order order); } @Service public class OrderServiceImpl implements OrderService { @Autowired private OrderDao orderDao; @Override @Transactional public void saveOrder(Order order) { orderDao.save(order); } } This...

Google Datastore app architecture questions

google-app-engine,transactions,google-datastore
I'm working on a Google AppEngine app connecting to the Google Cloud Datastore via its JSON API (I'm using PHP). I'm reading all the documentation provided by Google and I still have questions: In the documentation about Transactions, there is the following mention: "Transactions must operate on entities that belong...

Can LINQ BeginTransaction works with new Context?

c#,linq,entity-framework,transactions
My project is using Ninject to develop, for example, I wrote 2 functions to Insert or Update to Database public class PersonRepository : IPersonRepository { private readonly DbContext _context; public PersonRepository(DbContext context) { _context = context; } public void InsertToDB(Person obj) { _context.Persons.Add(obj); _context.SaveChanges(); } public void UpdateToDB(Person obj) {...

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

java,java-ee,transactions,ejb
My runtime exception @ApplicationException(rollback=false) public class UncheckedException extends RuntimeException {} My EJB code @Stateless @Transactional(TxType.REQUIRES_NEW) public class ContainerManagedTransactionBean { @PersistenceContext EntityManager em; public void insertAndThrowUnchecked() throws UncheckedException { em.persist(new Entry()); throw new UncheckedException(); } } My another EJB is client @Singleton @Startup @Transactional(TxType.NOT_SUPPORTED) public class Start { @EJB ContainerManagedTransactionBean bean;...

Spring @Transactional on @Bean declaration instead of class Implementation

java,spring,jpa,transactions
I'd like to configure "transactional" beans from my Spring @Configuration class instead of annotating the class implementation itself with @Transactional. Kind of like the old school way, configuring transactional advice from an XML file, but without needing a String reference to my class/method names to create pointcuts. The reason is...

hibernate rollback not working in service layer

hibernate,postgresql,transactions,junit4,spring-4
i have issue in rollback insert/update data in postgresql database, in service layer, where as in DAO layer it is working fine. My DAO junit test Code @ContextConfiguration("classpath:datasource-context-test.xml") @RunWith(SpringJUnit4ClassRunner.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) @Transactional public class SellerDAOTest { @Test @Rollback(true) public void testAddSeller() { try { SellerDO sellerDO...

Atomic increment of counter column using simple update

sql,transactions,sql-update,atomic
I am trying to understand how to safely increment a counter column, that may be incremented simultaneously by many users (It's a Web API for a mobile app). I've read the popular questions in SO for strategies dealing with the issue but I can't seem to figure what's wrong with...

Does ActiveMQ support multiple transactional consumers?

transactions,apache-camel,activemq,servicemix
I am developing OSGI bundles in ServiceMix to consume from the same queue of ActiveMQ. I need to be sure that the message is dequeued only if every thing goes fine so that I don't lose that message. So I used camel transactional client. I manged to implement it by...

Transactional annotation does not save on exit

spring,hibernate,jpa,transactions
I have configured spring jpa with annotation driven. I would expect the following code to persist the changes to the database upon method exist. @Transactional public Foo changeValue(int id){ final Foo foo = fooRepository.findOne(id); if(foo != null){ foo.setValue("new value"); //fooRepository.save(foo); } } FooRepository is a JPARepository and the foo object...

Communication to caller of method annotated @Transactional

java,spring,transactions
I have a method on which I am using the Spring @Transactional annotation: @Transactional public void persistAmendments(int _cutsheetId) { ... } If a condition occurs which forces a rollback of this transaction, how will a caller of persistAmendments() know about this? I would like my calling code to handle the...

Calling Fragment from inside the BaseAdapter class in PageViewer Android

android,android-fragments,tabs,transactions,android-viewpager
Hi I am new to Android and am using PageViewer in my project to show Tab swiping and other such stuff I have used 4 tabs and and used fragments for each tab Now 1 of the tabs I have a list on which button is there to call another...

SQL Server Rolls back my transaction when using THROW

sql-server,transactions,throw
I have an INSERT trigger on one of my tables that issues a THROW when it finds a duplicate. Problem is my transactions seem to be implicitly rolled back at this point - this is a problem, I want to control when transactions are rolled back. The issue can be...

Can RPUSH and LPUSH in Redis race?

transactions,redis,race-condition
The docs at redis.io on RPUSH and LPUSH aren't clear on whether or not these operations are still O(1) and transational when pushing multiple items. For example, if two clients perform an RPUSH to the same list with multiple items, can their items become interspersed and thus out of order?...

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

c#,sql-server,transactions
What is the better place to implement SQL transaction? Within application program's business logic or In side stored procedure? Is it a bad practice to open SQL transaction within the business logic code? when we are handling complex business logic such as a batch process? Please explain me what is...

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

mysql,transactions
In mysql database the command which we have use to insert, update and delete data are defaultly Transaction ? I mean to say, If we insert 1 corore rows from one table to another and the connection break from some reason, then the half rows are being insert or nothing...

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

transactions,cassandra,acid
Cassandra does not guarantee atomic behavior so there is a slight chance that one replica fails but other replica do persist the change. Are there any information how to defend against this and what to do in order to heal it if it happens? Does Cassandra heal itself in that...

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

php,yii,pdo,transactions,session-variables
I am currently working on a project to uses Yii and stumbled across something that made me scratch my head. I started a db transaction using Yii (which just calls PDO::beginTransaction) and did some database stuff and at the end, store a flash message for the user and do a...

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

google-app-engine,transactions,gae-datastore
We have an issue where we want to lazily create an entity if it does not exist. There is some discussion going on about how to do this and I would like to clarify some things around app engine transactions. I will limit my query to single entity group transactions....

Grails: Store audit record regardless of success/failure?

hibernate,grails,transactions,audit
In Grails, what is the recommended pattern to write an audit record for certain actions regardless of how the transaction ends? Example: Online user registration attempt that may fail for a number of reasons. Basic assumption, business logic is confined to transactional service methods. Underlying uncertainty: Should I abort a...

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

java,spring,transactions,spring-aop,spring-annotations
On the spring docs, for never propagation: Execute non-transactionally, throw an exception if a transaction exists. I wanted to try like following: @Transactional(propagation = Propagation.NEVER) public void getDeps(long ID) { System.out.println(databaseImp.getDepartmentByID(ID)); } @Transactional(propagation = Propagation.REQUIRED) public void allProcessOnDB_second(long ID) { getDeps(ID); operation(ID); } @Transactional public void operation(long id){ System.out.println(databaseImp.getDepartmentByID(id)); }...

Spring @Transactional how to “stop” transaction

java,spring,transactions,transactional
I have a controller that calls a method on a service class which should do the following: update database (using DAO 1) update database (using DAO 2) sendEmail (using email service) (1) and (2) should be atomic and if both succeed the email should be sent. If I annotate the...

Trigger to cancel transaction

sql,oracle,triggers,oracle11g,transactions
I have to enforce a rule based on a relatively complex query involving four tables. If any of the tables updates/inserts/deletes, I need to run the same query to check if the operation should be denied (by throwing an exception). I think there must be four separate triggers because it...

Spring JavaFX @Transactional entitymanager is closed

spring,exception,javafx,transactions,transactional
i'm stuck on a Transactional Problem using Spring @Transactional with a JavaFX application, all my beans, and graphical components are managed by spring. I initialize my appusing @PostConstruct on my Controllers. In the PostConstruct, all my daos are working perfectly but when i invoke a service to save something by...

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

java,spring,hibernate,jpa,transactions
I'm playing around a bit with Spring and JPA/Hibernate and I'm a bit confused on the right way to increment a counter in a table. My REST API needs to increment and decrement some value in the database depending on the user action (in the example bellow, liking or disliking...

Hibernate : Stale state exception

java,spring,hibernate,spring-mvc,transactions
I am working on a Spring-MVC application in which I am trying to delete an object from the database. Some days back, this error all of a sudden started, and now I am unable to delete. I checked on net, but I cannot find what am I doing wrong and...

Fragment Transactions with transition - Unique transitionNames are required

android,transactions,fragment,transition,android-transitions
I want to go from a list view to the detail view and therefore, I use following OnClickListener in my list: @Override public void onClick(View view) { Bet bet = (Bet)view.getTag(); FragmentManager fm = getActivity().getSupportFragmentManager(); BetDetailFragment f = BetDetailFragment.create(bet); String tag = f.getClass().getName(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setSharedElementReturnTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move));...

Downside of using transaction dispose with entity framework integration testing

entity-framework,transactions,entity-framework-6.1
I am looking for a quick way to clean my tables data doing integration tests with EF. Everyone seems to wrap a transaction around its test method and dispose the transaction after the test. That way the data is never written to the table. Things like new auto ids for...

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

hibernate,tomcat,transactions,sql-server-2012,connection-pooling
I'm monitoring the SQL database for connections every 5 minutes. For days it'll hover around 5 connections (my idle) then suddenly I'm at 50. Obviously this is a recursive issue because I can't see why I would jump from 5 to 50 within 5 minutes with zero traffic. I'm using...

Is spring transaction is only working in entering service method?

mysql,spring,transactions,spring-transactions
I have read many stackoverflow's pages about spring transaction. My spring transaction config is <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> My service is like this. @Service public class TestServiceImpl implements TestService { @Override public void testRollback() { testRollbackSecondLevel(); } @Transactional @Override public void testRollbackSecondLevel() { // any update sql in here carCostService.testUpdate(); throw...

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

transactions,asp.net-mvc-5,storage,windows-azure-storage,azure-virtual-machine
I am coding a MVC 5 internet application that is being stored on an Azure VM. In this internet application, user can upload files such as images and videos that can be accessed by the public via a url. My question is this: Should I store this uploaded data in...

Camel consume single message and stop, transacted

java,transactions,apache-camel,consumer,once
I am trying to use Camel to consume a single message from a JMS queue in a transacted manner. Specifically in a flow like this: Wait until message is published on JMS queue Try to consume and process the single message If processing fails (exception occurs), rollback the consumption If...

Fewer Columns In INSERT Statement Than In Values Clause

sql-server,insert,transactions,identity
I have a table in SQL Server with 34 columns. The identity column is an auto-incremented primary key and thus, not included in the INSERT statement. Therefore, I have 33 parameters in my INSERT statement. After checking, double-checking, and cross-checking my INSERT statement and the table, I keep getting the...

EntityManager nested transaction atomicity

java,java-ee,jpa,transactions,eclipselink
In legacy code I solving problem with nested transactions. (Spring, CDI, etc cannot be used only pure JPA(EclipseLink)) em.getTransaction().begin(); em.persist(client); em2.getTransaction().begin(); em2.persist(client1); //saved into DB em2.getTransaction().commit(); em.getTransaction().rollback(); public void method(){ EntityManager em = entityManagerFactory.createEntityManager(); em.getTransaction().begin(); em.persist(client); nestedTransactionMethod(); em.getTransaction().rollback(); } public void nestedTransactionMethod(){...

Sequelize - Inserting multiple associated entities in transaction fails

transactions,associations,sequelize.js
I have two models: Status and StatusParameter. Status 'hasMany()' StatusParameter and StatusParameter 'belongsTo()' Status. I want to insert a Status record and then insert multiple StatusParameter entities associated to the new Status. I want to wrap all the inserts in a transaction as well. I am using Sequelize 2.0.5, so...

Transaction with binded thread connection in Spring

spring,jdbc,transactions,spring-transactions
I want to bind a connection to a thread, and use that connection for any JdbcTemplate calls, to finally commit the changes or do a rollback. I'm declaring all sentences from a Groovy script, so I can't control how many SQL query will be call, that's why I have to...

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

java,spring,hibernate,transactions
I am facing a problem that when I use hibernate+spring+mysql to commiting my data from pages to database,the transaction didn't commit. Or perhaps my configuration is somewhere wrong. The following is my configuration and code: 1.spring-config.xml(The configuration of spring) <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver"></property> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/webtest?charset=UTF-8" /> <property...

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

concurrency,transactions,locking,orient-db
Having read the following statement from the official documentation of OrientDB: In order to guarantee atomicity and consistency, OrientDB acquire an exclusive lock on the storage during transaction commit. I am wondering if my understanding of the situation is correct. Here is how I assume this will work: Thread 1...

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

ruby-on-rails,ruby,transactions
I have a form where a user can update multiple resources at the same time. The transaction block makes the form atomic: if one validation fails for any of the resources being updated, then none of the resources get updated, and active record rollsback all changes. When transaction fails, I...

SimpleMessageListenerContainer ChannelTransacted and MaxConcurrentConsumers

transactions,rabbitmq,amqp,spring-amqp
I'm trying to configure a SimpleMessageListenerContainer from Spring AMQP with channeled transactions to dynamically add consumers on demand. The problem is, I don't see consumers being added dynamically when I have a channeled transaction. To be clear, this doesn't dynamically add consumers under load: container.setMaxConcurrentConsumers(5); container.setChannelTransacted(true); container.setTransactionManager(rabbitTransactionManager); But this does:...

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

transactions,jboss7.x,jta
I was wrestling with the problem of making sure a transaction is committed before other commands are executed. I didn't get an answer, but BalusC expressed his incredulity that my... "JSF managed bean is transactional..? This is not the default behavior. What annotations do you all have on your JSF...

What is the right way to use multiple savepoints

sql,sql-server,transactions,savepoints
I'm using transactions for the first time, so I might be asking a silly question. I want to insert data in 3 tables: Table1(p1,p2,p3) Table2(q1,q2) Table3(t3,fk1,fk2) For example, if something goes wrong and data cannot be inserted into Table2, data from Table1 will not be lost and Table3 remains unchanged...

Transactions in php function or in mysql stored procedure?

php,mysql,pdo,transactions
What is better way to begin a transaction? Inside procedures or PHP functions? For example I calling MySQL procedure like this: function sendLeaguesToDb(){ $leagues = ""; try{ $this->PDO->beginTransaction(); $stmt = $this->PDO->prepare("call insupd_Leagues(:id,:name,:country,:sport_id,:his_data,:fixtures,:livescore, :numofmatches,:latestmatch)"); $leagues=$this->soccer->GetAllLeagues(); foreach($leagues as $key=>$value){ $stmt->bindParam(':id',$value->Id); $stmt->bindParam(':name',$value->Name);...

Codeigniter: Loop in start_transaction

php,codeigniter,activerecord,transactions
I'm using for loop in a transaction. I have a question about this loop. While it's inserting e.x 100 rows to database, among inserting, if another person wants to insert, does it make problem, or insert_id() won't change? Thanks. $this->db->trans_start(); $query = $this->db->query("INSERT INTO category (Cat_Name, Subname, IsActive, Description) VALUES(?,...

How to handle transaction rollback with JMS and JPA in a Java EE environment?

java,jpa,transactions,jms,weblogic
The default rollback behavior for a CMT MDB is to return the message to the destination so it may be processed again. Is it possible to avoid redelivering a message handled by a managed MDB even if the the transaction is rolled back? (Or maybe configure the acknowledgement behavior handled...

Spring JPA transaction in clustered environment

spring,jpa,transactions,cluster-computing,jta
I use Spring-JPA in my application. I use container managed option for EntityManager and use JTA transaction manager. this Java EE application is deployed in JBoss clustered environment, will the isolation of transactions be taken care of? In other words, will two different requests on different JBoss nodes and two...

EjbConetxt setRollbackOnly vs ApplicationException rollback true

java,transactions,java-ee-6
I have a method which throws an application exception with rollback true. I wonder if I have to explicitly call ejbContext.setRollbackOnly() or not? The docs here says that we need not call the EjbContext's setRollbackOnly when the exception is marked as rollback=true. In my case I catch a ApplicationException whose...

Manage rollback on transaction in my managed bean

java,spring,hibernate,transactions,rollback
I am using JPA/hibernate, Spring and JSF. so my application is organized as following: I have my entities, My Dao Interface and implementation for each entity where I define basic methods: findById , add , update , remove ... and then I have my service layer which just use DAO...

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

android,ios,transactions,in-app-purchase,in-app-billing
I have used in-app purchase version 3. I don't know how to restore transaction means when user purchased one feature then how to store that transaction and how to get that transaction when user again used(like first installed then uninstalled and finally again installed) then i want to restore the...

C# MySQL Transaction commit

c#,mysql,transactions
I want to update ~50 rows. So i do it in a foreach The Code run without any errors but there are no changes in the database. public void updateItems(List<product> prdList) { MySqlTransaction tr = null; try { tr = this.con.BeginTransaction(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = con; cmd.Transaction...

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

java,sql-server,transactions
I am running a Spring Java Web Application which can communicate with a database. The type of database is selectable by the user and can be MySQL, Oracle or SQLServer. I don't understand why the following code fails to drop the table when using SQLServer ONLY (it works for Oracle...

Why does MVCC require locking for DML statements

postgresql,transactions,locking,dml,mvcc
In PostgreSQL, the MVCC concurrency control mechanism says that: MVCC locks acquired for querying (reading) data do not conflict with locks acquired for writing data, and so reading never blocks writing and writing never blocks reading So, even for READ_COMMITTED, an UPDATE statement will lock the currently affected rows so...

Spring 4 + JPA (Hibernate 4) + JTA transaction manager doesn't flush automatically

java,spring,hibernate,jpa,transactions
I am migrating an application from Spring 3.0.5 + JPA 2.0 to Spring 4 + JPA (Hibernate 4) I have followed the migration guide : https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework. The application is using a JTA transaction manager : a Jencks / GeronimoPlatformTransactionManager (because of transactions distributed on datasources and ESB). The Spring /...

Auto-COmmit of DDL

mysql,transactions,persistence,rdbms,ddl
I read that "CREATE TABLE" and "DROP TABLE" statements are auto-commit. I am trying to understand their behaviour for the below scenario: conn.setAutoCommit(false); stmt = conn.createStatement("CREATE TABLE ..."); conn.commit(); In the above case, would setting autoCommit to false would have any impact on CREATE TABLE auto-commiting. If conn.setAutoCommit(false) does override...

ORMLite + Transactions

transactions,ormlite
I have a problem understanding the default behavior of the DaoManager. DaoManager.createDao(connectionSource, theClass); This takes a connectionSource - not a connection. So if I do the following: TransactionManager.callInTransaction( localConnection, connectionSource.getDatabaseType(), new Callable<Void>() { public Void call() throws Exception { dao.create(user); dao.create(player); return null; } }); The transaction should be limited...

ServiceStack OrmLite and transactions

sql-server,transactions,ormlite-servicestack
I am trying to execute sql inside a transaction using ServiceStack OrmLite. The code below works with Sqlite but not with SqlServer. With SqlServer I get the following error: ExecuteScalar requires the command to have a transaction when the connection assigned to the command is in a pending local transaction....

How to set up 2 IBDatabase to 1 IBTransaction?

delphi,transactions,database-connection
I have one IBDatabase in DataModule linked with my IBTransaction. In one module of project I need to control the persistence in two database. For this, I am adding the second IBDatabase this way: constructor TConnections.Create(AIBDatabase: TIBDatabase); begin if AIBDatabase = nil then raise Exception.Create('The base connection is needed!'); inherited...

Wildfly - Infinispan Transactions configuration

java,transactions,ejb,wildfly,infinispan
I am using Wildfly 8.2 with its included Infinispan (6.0.2) and I am trying to cache all values from some Oracle database table in an Infispan cache. In most cases, it seems to work, but sometimes it does not. When accessing the cache.values() (which also may not be a good...

Prevent previously loaded entity being updated in transactional method

java,spring,transactions
I have the following method in one of my services @Override @Transactional public void createUserInfo(long userId, UserInfo userInfo) { User oldUser = userService.findUserById(userId); if (oldUser.infoIsTheSame(userInfo)) { return; } User updatedUser = userService.addUserInfo(userId, userInfo); feedService.addFeed(FeedAction.INFO_UPDATE, oldUser, updatedUser); } As you can see findUserById() and addUserInfo() methods are in the same service,...

Insert transaction if not exists in SQL Server

sql,sql-server,insert,transactions,procedures
I want to insert in the table only if I do not have the specific column it is a track table with different titles and I want to add different titles with one procedure I did the try catch and I have problem in my where not exists condition, I...

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

transactions,rpc,bitcoin
I'm trying to create my own display of the blockchain and I encounter an understanding problem. I'm using txindex=1 in bitcoin.conf to have access to non-wallet information on transactions but when I decode a rawtransaction I cannot make the difference between the change and the amount of the transaction. Here...

Integrity while reading from two tables: orders and order_items

database,postgresql,transactions
I'm looking for a method of achieving data integrity while reading from the database (which does not use a lot of resources, hopefully), without adding new fields into the schema. By integrity I mean the integrity between order sum in orders table and sum of order item prices: orders (id...

How does Spring Batch manage transactions (with possibly multiple datasources)?

java,transactions,spring-batch
I would like some information about the data flow in a Spring Batch processing but fail to find what I am looking for on the Internet (despite some useful questions on this site). I am trying to establish standards to use Spring Batch in our company and we are wondering...

Rails on create transaction

ruby-on-rails,devise,transactions
On creating a new user (in my user model) i want to create a stripe customer as well. The two actions must only be completed if they succeed together (like i don't want a customer without a user and vice versa). For this reason I figured it would be a...

MySQL delete and remove from many-to-many table in one transaction

php,mysql,transactions,many-to-many,model-associations
Is it possible to delete from association table (many-to-many) and insert same row to it in the same transaction? This is my association table: CREATE TABLE image_tag ( imageid bigint(19) NOT NULL, tagid bigint(19) NOT NULL, PRIMARY KEY (imageid, tagid)); ALTER TABLE image_tag ADD INDEX FKimage_tag587679 (tagid), ADD CONSTRAINT FKimage_tag587679...

Informix to PostgreSQL - Transaction Function

sql,postgresql,transactions,plpgsql,informix
I need to convert my Informix function to PostgreSQL. Problem is that I know PostgreSQL doesn't allow to call BEGIN WORK and COMMIT in function so I don't know how to handle my exceptions and rollback that way. Function that I want to convert looks like this: CREATE PROCEDURE buyTicket(pFlightId...

Laravel 4.2 - Transaction rollback issue with multiple databases

php,laravel,pdo,transactions
I am experiencing issues in rolling back a transaction involving tables from multiple databases. The primary table rollback behaves as expected, but the child row remains, and is now orphaned. public function devUserCreateTest() { DB::beginTransaction(); try { $childUser = new ChildUser; // Exists in database B $parentUser = new User;...

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

java,multithreading,spring,hibernate,transactions
We have a java, spring, osgi application with a jersey REST interface. In that setting I need to send data to a mobile device running winCE CF 3.5 so it has only 4 MiB RAM per process. This means even a thousand data objects let the MDEs memory over flow. To solve...

Ensure concurrent (money) transactions in Entity Framework?

c#,mysql,entity-framework,transactions,atomic
Assume I have an account_profile table, which has Score field that is similar to an account's money (the database type is BIGINT(20) and the EntityFramework type is long, because I don't need decimal). Now I have the following function: public long ChangeScoreAmount(int userID, long amount) { var profile = this.Entities.account_profile.First(q...

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

python,django,transactions,isolation-level,transaction-isolation
I have a function, that does multiple queries on the same dataset and I want to ensure all the queries would see exactly the same data. In terms of SQL, this means REPEATABLE READ isolation level for the databases that support it. I don't mind having higher level or even...

What data is stored in transaction?

database,spring,data,transactions,transactional
Which data is stored in @Transactional services, especially in the transaction? If I have a controllers layout, services layout, daos and database - why I have to use my services with @Transactional annotation and what data is stored between these layouts? For example, I send some object data and I...

How to force flushing in Grails GORM

grails,transactions,flush
I have a service that distributes tasks to operators. Inside a method I distribute many tasks in time inside a loop. I want to flush the task, the operator, and a DistributionLog. If I just had one domain to save I think I could do something like Operator.withTransaction{ //...some code...

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

java,spring,hibernate,transactions,jboss7.x
After upgrading my application from JSF 1.2 to JSF 2.1 I have the following Spring Hibernate exception when trying to login: DEBUG,[interceptor.ExceptionInterceptor][],org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: commit failed at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:472) at...

Multiple transaction managers - Selecting a one at runtime - Spring

java,spring,transactions,spring-transactions
I am using Spring to configure transactions in my application. I have two transaction managers defined for two RabbitMQ servers. .... @Bean(name = "devtxManager") public PlatformTransactionManager devtxManager() { return new RabbitTransactionManager(devConnectionFactory()); } @Bean(name = "qatxManager") public PlatformTransactionManager qatxManager() { return new RabbitTransactionManager(qaConnectionFactory()); } @Bean public ConnectionFactory devConnectionFactory() { CachingConnectionFactory factory...

JPA difference between transaction isolation and entity locking

java,database,jpa,concurrency,transactions
I have read about transaction isolation levels. It is used to prevent parallel transaction executions errors. Its quite obvious. There are also locking modes available for entities. I understand how they work. But I cant find the reason why I need locking? I have used transaction isolation levels already. Why...

PDO Transaction with Prepared Statements not working

php,mysql,pdo,transactions,prepared-statement
I have a PDO Transaction in which I'm trying to use prepared statements to run two queries on my database. They're both insert statements, they insert data from Facebook into two separate tables (named "player" and "bank"). The Facebook data is sent to this php script by an AJAX post....

Cakephp3 transaction find query

mysql,select,transactions,cakephp-3.0
When making a transaction in cakephp3 and adding a get() query inside all works fine. But why is a find() query not performed inside the transaction? I have the following controller in cakephp3: <?php namespace App\Controller; use Cake\Core\Configure; use Cake\Network\Exception\NotFoundException; use Cake\View\Exception\MissingTemplateException; use Cake\Network\Session; use Cake\Event\Event; use Cake\Network\Http\Client; use Cake\ORM\TableRegistry;...

Spring transaction management

java,spring,hibernate,spring-mvc,transactions
I am working on spring4 mvc to introduce in our new web application and currently we are using struts1.x and wanted to use new framework for support html5/ajax request as simple as possible and wanted to use the power of DI and spring webflow support. Currently in our struts1.x application...

SQLite multithread - avoid unnecessary blocking for readers

php,multithreading,sqlite,transactions
Quite a long time ago I wrap all my transactions on multitread app (php scripts) that use the same sqlite database into BEGIN IMMEDIATE TRANSACTION. I remember, I read somewhere at SO that: need to wrap all transactions withBEGIN IMMEDIATEon multithread environment to avoidSQLITE_BUSY` state. Now, I'm thinking about some...

Get all transactions on monday between 10 and 11am

django,datetime,django-models,transactions
I'm wondering if it is possible to use Django on a database of transaction to get all transaction that happened on a(ll) Monday(s) between 10 and 11. For completeness here is the model definition: class P1data(models.Model): date_time = models.DateTimeField(auto_now_add=True, db_index=True) price = models.DecimalField(max_digits=40, decimal_places=12) volume = models.DecimalField(max_digits=40, decimal_places=12) ...

PHP/MySQL Critical section

php,mysql,transactions,innodb,critical-section
I'm using PHP with PDO and InnoDB tables. I only want the code to allow one user-submitted operation to complete, the user can either cancel or complete. But in the case that the user posts both operations, I want one of the requests to fail and rollback, which isn't happening...

How to delete previous table transaction if next table transaction fails

c#,sql,asp.net,sql-server,transactions
I'm inserting some data to tables one by one. I've two tables adjustment_header and adjustment_grid. First I'll insert data to adjustment_header table then I'll insert data to adjustment_grid table. If adjustment insertion fails, previously inserted data in adjustment_header table should be delete automatically. Is there any query for this kind...

Why my mysql transaction is not working properly?

php,mysql,mysqli,transactions,database-connection
I've been reading and gathering information for 2 days already and I give up. I have no clue why my piece of simple code is not succeeding. I want to insert data from one form into two tables and YES I know there are exactly same problems described here and...

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

java,spring,hibernate,spring-mvc,transactions
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...

Oracle: do Truncates maintain Atomicity within a transaction?

database,oracle,oracle11g,transactions,oracle10g
Oracle 10g -- due to a compatibility issue with a 9i database, I'm pulling data through a 10g database (to be used by an 11g database) using INSERT INTO...SELECT statements via a scheduled job that runs every 15 minutes. I notice that TRUNCATE statements are much faster than DELETE statements...

Integration Tests for WebAPI and transactions

rest,asp.net-web-api,transactions
I have a client facing ASP.NET Web API which has both direct SQL server calls as well as calling other ASP.NET Web APIs to do data operations. I want to do an end to end integration test of the client REST API to test the routes of the other called...

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

java,spring,jpa,transactions
I have some code that looks like this: @Transactional(noRollbackFor = { CannotAcquireLockException.class, LockAcquisitionException.class }) public void deleteSomeData() { int backOffTime = 0; int fibonacci = 1; boolean executed = false; do { try { this.myDAO.deleteTheData(); executed = true; } catch (RuntimeException rt) { int newBackoffTime = backOffTime + fibonacci; fibonacci...

How can I add FOR UPDATE to a cakephp3 query?

select,transactions,sql-update,cakephp-3.0,isolation-level
Is there a way to add FOR UPDATE to a find (SELECT) query in cakephp3? I found this hack: http://bakery.cakephp.org/2012/04/14/SELECT-FOR-UPDATE-hack-kind-of-ugly-but-it-works-PostgreSQL-and-MySql.html but it does not work since the limit value must contain only of a number. Another discussion on a similar topic can be found under https://github.com/cakephp/cakephp/issues/3136#event-213462937....

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

python,django,transactions
In Django 1.4 I have a code like the following: from django.db import models from django.db import transaction class MyModel(models.Model): # model definition @transaction.commit_manually def save(self, *args, **kwargs): try: super(MyModel, self).save(*args, **kwargs) do_other_things() except: transaction.rollback() raise else: transaction.commit() obj2 = MySecondModel(mymodel = self, foo = "bar") obj2.save() class MySecondModel(models.Model): myModelId...

SQL Azure Connection and Transaction

transactions,sql-azure,saas
I am using SQL Azure for a Saas based asp.net application. I have avoided transactions as much as possible to prevent deadlocks for end-users. This is due to my lack of knowledge in DB Design, but I thought avoiding transaction is atleast one sure way of reducing table and row...

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
As described here (relevant parts), https://www.playframework.com/documentation/1.3.x/jpa Play will automatically start the Hibernate entity manager when it finds one or more classes annotated with the @javax.persistence.Entity annotation... When the JPA entity manager is started you can get it from the application code, using the JPA helper... Play will automatically manage transactions...

SSIS 2012 Transaction in ForEach Loop

ssis,transactions,ssis-2012,foreach-loop-container
I have a package that iterates several times, one for each Category. I put a transaction in the package such that each Category completes in full or not at all. If I have 3 Categories, A B and C, and Category B fails, I want to ensure that A and...

Spring Transaction Isolation Level

java,mysql,spring,hibernate,transactions
Most of us might be using Spring and Hibernate for data access. I am trying to understand few of the internals of Spring Transaction Manager. According to Spring API, it supports different Isolation Level - doc But I couldn't find clear cut information on which occasions these are really helpful...

Get current database transaction id using jdbc/hibernate?

java,mysql,hibernate,jdbc,transactions
I've looked around on Google for this but couldn't find anything relevant. Basically, I want to get hold of long running transactions. For now, I go through information_schema.INNODB_TRX or have a look at the output of show engine innodb status to find the trx_id and then turn on general_logs to...

Mysql Transaction: Effect on other Transaction query

php,mysql,sql,database-design,transactions
I am writing an application which shall track the financial transactions (as in a bank), to maintain the balance amount. I am using Denormalizing technique to keep the performance in check(and not have to calculate the balance at runtime) as discussed Here and Here. Now, I am facing a Race...

SQLite3 — Return Affected Rows

jdbc,sqlite3,transactions
Supposing I have a schema with a name field and an int field. I want to get one random entry where the int value is 1, set it to 0, and return the name of the entry that was changed in a transactional manner. What's the best way to do...

Google Analytics duplicate transaction id multiple domains

google-analytics,transactions,google-tag-manager
I am implementing Google Analytics (via GTM) on multiple ecommerce sites. I need to record transactions to the client's google analytics account as well as to our single master analytics account, which accrues data for multiple sites. I am wondering if there will be any issues sending duplicate transaction ids...

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

java,transactions,cassandra,datastax-java-driver
Do Cassandra lightweight transactions use an implied SET, and so can not have an IF part in terms of a primary key? I ask because the Datastax Cassandra Java driver (version 2.1.5) throws an InvalidQueryException while I'm preparing a statement. The exception message is clear enough: PRIMARY KEY part name...

Transactions and Eloquent

php,laravel,transactions,eloquent,laravel-5
I want to use transactions in my laravel application. However, I struggle to use them with Eloquent. $user = $this -> auth -> user(); DB::transaction(function() { $stores_amount = $user -> stores() -> count(); #Error }); I get an "Undefined variable: user" error. What is my problem and how can I...

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

c#,asp.net,.net,visual-studio-2013,transactions
This is in an ASP.Net web application, with Visual Studio 2013. The solution is composed of several projects. I have code in a library project that has using System.Transactions, and it's worked well for months. Today I added the same using System.Transactions in code in the web application project, and...

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 I have reads/writes configured in database.php, and I start a transaction like DB::transaction(function() { // series of reads and writes }), will everything run on the write connection, or will there be two separate transactions, or will it just explode?