transactions

Difference between @Transactional and @TransactionAttribute

倾然丶 夕夏残阳落幕 提交于 2019-12-23 09:53:15
问题 I started persistence coding and I came across annotations such as @Transactional and @TransactionAttribute . I understand the basic functionality of these two annotations and also that they can be used at both class level and at the method level. What I would like to understand better is the difference between these two annotations. Any help would be appreciated. Thanks. 回答1: @TransactionAttribute is for EJB3 beans. @Transactional is for POJOs (for example Seam, Spring/Hibernate). 来源: https:

SQL Server: Deleting Rows with Foreign Key Constraints: Can Transactions override the constraints?

£可爱£侵袭症+ 提交于 2019-12-23 09:34:35
问题 I have a few tables where Foreign Key constraints are added. These are used with code generation to set up specific joins in generated stored procedures. Is it possible to override these constraints by calling multiple deletes within a transaction, specifically "TransactionScope" in C# or is cascaded deleting absolutely required? 回答1: Do not use cascade delete, you can cause serious performance issues that way. The best procedure is to do the deletes in order from the lowest child table up to

ColdFusion: Multiple SQL statements in a query?

爱⌒轻易说出口 提交于 2019-12-23 08:54:48
问题 Apparently ColdFusion doesn't like multiple SQL statements within a single query... so what once was this: SET @sender_user_id = 3, @recipient_user_id = 5; INSERT INTO messages (message_type, sender_id, message_title, message_content) VALUES(3, @sender_user_id, 'One more thing...', 'I am testing this message'); SET @saved_message_id = LAST_INSERT_ID(); INSERT INTO message_recipient (message_id, user_id) VALUES(@saved_message_id, @recipient_user_id); INSERT INTO message_status (message_id,

Postgres setting autocommit off globally

空扰寡人 提交于 2019-12-23 08:47:29
问题 How do you set autocommit off in psql 8.4 at a global level? is there a configuration attribute that i can change that will introduce this behaviour for all dbs on a cluster to start db sessions with autocommit off? 回答1: Simply add the following to ~/.psqlrc : \set AUTOCOMMIT off Note that this only works when using the psql shell! I assume this is what you are talking about? 回答2: Use a transaction if you want want a (open) transaction: BEGIN; INSERT ...; UPDATE ...; COMMIT; -- when you're

View open transactions in Oracle

一曲冷凌霜 提交于 2019-12-23 08:35:15
问题 How can I see open transactions in Oracle ? I'm doing a custom performance tool, and I'd like to see the number of currently open transactions. Is there a SQL request to do that, or another way to gather this information ? 回答1: Use view v$transaction 来源: https://stackoverflow.com/questions/4470593/view-open-transactions-in-oracle

View open transactions in Oracle

半城伤御伤魂 提交于 2019-12-23 08:34:37
问题 How can I see open transactions in Oracle ? I'm doing a custom performance tool, and I'd like to see the number of currently open transactions. Is there a SQL request to do that, or another way to gather this information ? 回答1: Use view v$transaction 来源: https://stackoverflow.com/questions/4470593/view-open-transactions-in-oracle

PostgreSQL : Transaction and foreign key problem

匆匆过客 提交于 2019-12-23 07:49:33
问题 I'm inserting a value in table A, that has a serial type as primary key. I wanna use the returned value of the query as a foreign key of table B... but I get this message: ERROR: insert or update on table "tb_midia_pessoa" violates foreign key constraint "tb_midia_pessoa_id_pessoa_fkey" DETAIL: Key (id_pessoa)=(30) is not present in table "tb_pessoa". ) How can I make this possible without: - starting a new Transaction - droping my foreign keys constraints =O ? Regards! Pedro 回答1: You can

Firestore transaction, implementing multiple gets

喜你入骨 提交于 2019-12-23 07:45:57
问题 Anyone know how to implement multiple gets in a Firestore Transaction? I have an array of Firestore References, of an unknown length, saved in Firestore. Each reference contains {count: number} and I just want to add one to each reference. To do this I am pretty confident I need to use transactions, and the docs say I can use multiple gets, but I'm not sure how to implement it. I would think I need to get each reference, store the existing counts in an array, add one to each, then save them

Firestore transaction, implementing multiple gets

妖精的绣舞 提交于 2019-12-23 07:44:22
问题 Anyone know how to implement multiple gets in a Firestore Transaction? I have an array of Firestore References, of an unknown length, saved in Firestore. Each reference contains {count: number} and I just want to add one to each reference. To do this I am pretty confident I need to use transactions, and the docs say I can use multiple gets, but I'm not sure how to implement it. I would think I need to get each reference, store the existing counts in an array, add one to each, then save them

How to avoid two different threads read the same rows from DB (Hibernate and Oracle 10g)

大憨熊 提交于 2019-12-23 07:39:25
问题 Let's suppose I got two different threads, T1 and T2, accessing concurrently the same database and fetching data from the same table. Now on thread startup I need to fetch data from the table and store the rows into a collection, that I will then use to perform some work elsewhere. I don't want the two threads to be able to process the same data, because it will result in duplicated (and long) work. To be more concrete, this is an enterprise application that needs to load some records at