rollback

JPA data access object - exception handling and rollback

北战南征 提交于 2019-12-10 19:49:48
问题 I'd like to know what the best way of exception handling in data access objects is, I'm interested in production quality code. As an example public UserDaoImpl implements UserDao{ @PersistenceContext private EntityManager em; void save(User user){ em.persist(user); } User getById(long id){ return em.find(User.class,id); } } Let's say that for example I have a RegisterService somewhere where at some point I'd like to save the user to the database. And that each User needs to have a unique

Transactions in GreenDao

可紊 提交于 2019-12-10 17:53:16
问题 I'm using GreenDao to store a lot of data, coming from a REST service . A lot of my entities are connected with relations. Everything works great, but tomorrow I have to implement a rocksolid workflow. When I load my data I have to check if an error occurs . If so, I have to make sure nothing is stored in the SQLite DB. Normally I would work with transactions and rollback in case of an exception, otherwise commit to the db. For now I just use insertordelete to save an entity, everytime I

Oracle 11 - sqlplus - rollback the whole script on error - how?

喜你入骨 提交于 2019-12-10 17:16:22
问题 How can I make Oracle 11g rollback the whole transaction on any error in included SQL file? The file contents are: set autocommit off whenever SQLERROR EXIT ROLLBACK insert into a values (1); insert into a values (2); drop index PK_NOT_EXIST; commit; And the file is included into sqlplus session using "@": @error.sql As expected, the sqlplus session terminates and the output is SQL> @error.sql 1 row created. 1 row created. drop index PK_NOT_EXIST * ERROR at line 1: ORA-01418: specified index

WiX. Rollback custom action when is canceled installation

﹥>﹥吖頭↗ 提交于 2019-12-10 16:36:50
问题 I have a custom action <CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" /> <InstallExecuteSequence> <Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom> </InstallExecuteSequence> My custom action does backup and resolved database. I need to do rollback (drop database) when is canceled installation. I did: <CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate"

How to rollback all statements inside a MySQL Transaction?

浪子不回头ぞ 提交于 2019-12-10 15:17:30
问题 I need to update a specific column of a table ( bigtable ) containing ids of another table (FK constraint to oldsmalltable ) to point to ids on another table (FK constraint to newsmalltable ). Basically this is what I am doing: DELIMITER // CREATE PROCEDURE updatebigtable () BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING ROLLBACK; START TRANSACTION; ALTER TABLE bigtable DROP FOREIGN KEY bigtable_ibfk_1, MODIFY smalltable_id SMALLINT ; UPDATE bigtable SET smalltable_id=CASE smalltable

Spring integration test does not roll back

こ雲淡風輕ζ 提交于 2019-12-10 14:16:54
问题 I'm using Spring + Hibernate + H2. I do database operations in my integration tests (by calling a service class). I want Spring to rollback the changes after each test method, but I can't get it to work. At first I used MySQL (with MyISAM, which doesn't support transaction), but after changing to H2 the problem remains. I tried several DataSource-definitions (after reading that it must be XA-aware), but nothing seems to help. I use http://code.google.com/p/generic-dao/ for my DAO-classes and

Why does rake db:rollback rollback three steps?

我们两清 提交于 2019-12-10 12:41:44
问题 Normally when I do $ rake db:rollback it rolls back one migration. But now, repeatedly times, it has rollbacked 3 steps. How come this behaviour? I'm on Rails 3.2.13. 回答1: You can specify the number of steps like this: rake db:rollback STEP=3 The STEP parameter is actually an environment variable here. If, in your terminal, you run the command echo $STEP , does it return 3? If it does, you can execute export STEP=1 to get back to expected behaviour. If it happens again, try to find out where

How to rollback an update in PostgreSQL

99封情书 提交于 2019-12-10 12:32:43
问题 While editing some records in my PostgreSQL database using sql in the terminal (in ubuntu lucid), I made a wrong update. Instead of - update mytable set start_time='13:06:00' where id=123; I typed - update mytable set start_time='13:06:00'; So, all records are now having the same start_time value. Is there a way to undo this change? There are some 500+ records in the table, and I do not know what the start_time value for each record was Is it lost forever? 回答1: I'm assuming it was a

Transaction rollback when exception in Spring

青春壹個敷衍的年華 提交于 2019-12-10 10:50:23
问题 I am learning Spring and I have some troubles with transaction in Spring. Here is my code @Transactional(rollbackFor = Exception.class) public void createGroupStudent(Student A,Student B,String nameGroup){ try{ //create Group createGroup(nameGroup); //createMember createMember(A,B); }catch(Exception e){ logger.error(e.getMessage()); } } @Transactional(rollbackFor = Exception.class) public void createGroup(String nameGroup){ try{ repoGroup.save(nameGroup); }catch(Exception e){ logger.error(e

PL/SQL: Contradiction in Oracle document on Implicit Rollbacks

耗尽温柔 提交于 2019-12-10 10:29:43
问题 In the document Oracle Database PL/SQL Language Reference 11g Release 2 (11.2), the "Implicit Rollbacks" section begins with this text: "Before running an INSERT, UPDATE, DELETE, or MERGE statement, the database marks an implicit savepoint (unavailable to you). If the statement fails, the database rolls back to the savepoint . Usually, just the failed SQL statement is rolled back, not the whole transaction." So if I run a SQL sentence into an PL/SQL program, and the sentence fails, then the