transactions

How to detect the last insert ID within a transaction in Yii using DAO?

五迷三道 提交于 2019-12-30 08:20:09
问题 That's the source code, I need to detect the ID (see the marked position between the two queries below). $connection = Yii::app()->db; $transaction=$connection->beginTransaction(); try { $q = "INSERT INTO `someTable1` .... "; $connection->createCommand($q)->execute(); // Single Row Inserted // HERE!! How to get the last insert ID from query above $q = "INSERT INTO `someTable2` .... WHERE id = LAST_INSERT_ID_FROM_FIRST_QUERY "; $connection->createCommand($q)->execute(); $transaction->commit();

Does Nhibernate session.BeginTransaction auto rollback on exception within Using

匆匆过客 提交于 2019-12-30 07:56:23
问题 Ok sorry for the long subject name... If I do the following: using (var transaction = session.BeginTransaction()) { // do something transaction.Commit(); } If my do something caused an exception, would it auto rollback, or do I need to explicitly check for this like below: using (var transaction = session.BeginTransaction()) { try { // do something transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } 回答1: It's a safe assumption that the transaction will be rolled back if

Are there multiple formats of In App Billing transactions?

冷暖自知 提交于 2019-12-30 07:12:09
问题 We're having problems verifying some of payment transactions (Google In App Billing V3). It looks like data of cumbersome transactions follows a different format than what we can see in transactions we have no problems verifying. Transactions that we are able to verify OrderId : Two numbers separated with a dot: 92299713162054702728.1224255970239541 Signature : Always includes base64 padding at the end, 345 characters long Transactions that fail to verify OrderId : One number:

How to propagate Spring transaction to another thread?

爱⌒轻易说出口 提交于 2019-12-30 07:03:16
问题 Perhaps, I am doing something wrong, but I can't find a good way out for the following situation. I would like to unit test a service that uses Spring Batch underneath to execute jobs. The jobs are executed via pre-configured AsyncTaskExecutor in separate threads. In my unit test I would like to: Create few domain objects and persist them via DAO Invoke the service method to launch the job Wait until the job is completed Use DAO to retrieve domain objects and check their state Obviously, all

Hibernate and JDBC in one transaction

ε祈祈猫儿з 提交于 2019-12-30 06:16:13
问题 I have a method, marked as @Transactional. It consists of several functions, one of them uses JDBC and the second one - Hibernate, third - JDBC. The problem is that changes, made by Hibernate function are not visible in the last functions, that works with JDBC. @Transactional void update() { jdbcUpdate1(); hibernateupdate1(); jdbcUpdate2(); // results of hibernateupdate1() are not visible here } All functions are configured to use the same datasource: <bean id="myDataSource" class="org

How to start a transaction in JPA using entityManager

醉酒当歌 提交于 2019-12-30 04:58:28
问题 I have started working on an application which uses spring, hibernate, JPA, SOAP webservices. Now there is a requirement that certain queries have to be run in a transaction. If any one fails, entire transaction should rollback. The code in the dao layer is as follows : import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContextType; import javax.persistence.Query; import org

Are SQL queries guaranteed to execute atomically when using UNION?

不想你离开。 提交于 2019-12-30 04:41:13
问题 I am issuing a single SQL query consisting of multiple SELECTs grouped using UNION: SELECT * FROM employee LEFT JOIN department ON employee.DepartmentID = department.DepartmentID UNION SELECT * FROM employee RIGHT JOIN department ON employee.DepartmentID = department.DepartmentID; Assuming I execute this query under READ_COMMITTED transaction isolation, are the two SELECT statements guaranteed to execute atomically? Or do I run the risk of data changing between individual SELECT statements?

Do triggers get rolled back if a transaction fails in SQL Server?

六眼飞鱼酱① 提交于 2019-12-30 03:59:09
问题 I have some triggers on some tables that perform a function when something is deleted or updated. During a transaction, if the trigger executes and later in the transaction it gets rolled back, does the trigger also get rolled back? 回答1: Yes. So long as the trigger fires as part of the transaction, any changes in makes within the database would also get rolled back. Nitpick - a trigger is a trigger, it will not get rolled back. The effects of the trigger will be. 回答2: OK, a real transaction

Does ndb.toplevel break transactions?

一曲冷凌霜 提交于 2019-12-30 03:20:49
问题 The following code works as expected and does not trigger the assertion: @ndb.transactional @ndb.tasklet def Foo(): assert ndb.in_transaction() The following code breaks, triggering the assertion: @ndb.transactional @ndb.toplevel def Foo(): assert ndb.in_transaction() I tried replacing the decorator with an ndb.transaction call or an ndb.transaction_async call, but neither worked. Is there a bug with ndb.toplevel and transactions? 回答1: I discovered that the problems is that both create new

Multiple transaction managers with @Transactional annotation

邮差的信 提交于 2019-12-30 01:54:06
问题 We have base generic manager which is inherited by all managers. Base manager is annotated with @Transactional annotations. There are 2 groups of transactional services: x.y.service1.* - have to be managed by transactionManager1 x.y.service2.* - have to be managed by transactionManager2 How can transactions be configured without nessesity to override ALL transactional methods and specify transaction manager? @Transactional(readOnly = true) public abstract class GenericManagerImpl<D extends