transactions

Entity Framework - Transactions replacing SaveChanges(bool) with SaveChanges(SaveOptions)

此生再无相见时 提交于 2019-12-22 04:21:09
问题 This is a follow up question to Using Transactions or SaveChanges(false) and AcceptAllChanges()? Specifically about this line context2.SaveChanges(false); Now SaveChanges(bool) is deprecated. We are supposed to use SaveChanges(SaveOptions) instead. The SaveOptions has following options: None AcceptAllChangesAfterSave DetectChangesBeforeSave Which of these map to SaveChanges(false)? 回答1: SaveChanges(SaveOptions.DetectChangesBeforeSave) is equivalent of SaveChanges(false) 来源: https:/

How to prevent “Local transaction already has 1 non-XA Resource” exception?

风格不统一 提交于 2019-12-22 04:15:12
问题 I'm using 2 PU in stateless EJB and each of them is invoked on one method: @PersistenceContext(unitName="PU") private EntityManager em; @PersistenceContext(unitName="PU2") private EntityManager em2; @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW ) public void getCandidates(final Integer eventId) throws ControllerException { ElectionEvent electionEvent = em.find(ElectionEvent.class, eventId); ... Person person = getPerson(candidate.getLogin()); ... } @TransactionAttribute

Handling Hibernate Transactions

为君一笑 提交于 2019-12-22 04:13:28
问题 Currently I have this code duplicated in each one of my Controller methods: Transaction transaction = HibernateUtil.getSessionFactory().getCurrentSession().getTransaction(); if (!HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().isActive()) { transaction.begin(); } Is this the correct way or is there a better way of doing this, perhaps in a separate class that I can reference? If so, how? Every time I've tried to put it in a separate class and reference it from other

How to scope NHibernate sessions and transactions in a WPF application

☆樱花仙子☆ 提交于 2019-12-22 03:28:42
问题 I am relatively new to both WPF and NHibernate and attempting to build an application that combines the two, using the MVVM pattern. However, I am struggling to understand when and where my application should open and close NHibernate sessions and transactions. From what I have read, it is recommended that sessions should be kept as short as possible. Therefore, aside from the obvious thread-safety considerations, I assume it is not correct to open a session at the application level and share

LINQ to SQL - Is it true that SubmitChanges() automatically starts a transaction?

浪子不回头ぞ 提交于 2019-12-22 01:33:46
问题 I need to use transactions with LINQ to SQL and I was reading around to get familiar with it. Is it true that SubmitChanges is already transactioned? 回答1: When you call SubmitChanges, LINQ to SQL examines the set of known objects to determine whether new instances have been attached to them. If they have, these new instances are added to the set of tracked objects. Immediately before any actual changes are transmitted, LINQ to SQL starts a transaction to encapsulate the series of individual

transaction handling : How are simultaneous transaction managed?

佐手、 提交于 2019-12-21 23:54:08
问题 Suppose a withdrawal transaction of 6000 is happening on account ABC(fund:1000) and at the same time a withdrawl of 8000 is carried out from ATM. Then how will the transaction be managed. Will the database open just one connection and doesnt allow new connection to the same account ?? .... What will happen in such cases when a transaction needs to be done on same account simultaneously and how are these things managed. 回答1: This is a good question on a very complex topic. There's a technical

Transactions in Apache Jackrabbit and Spring

时光总嘲笑我的痴心妄想 提交于 2019-12-21 23:43:00
问题 I want to run transactions on my Spring webapp which uses Apache Jackrabbit repository. JackRabbit then uses relational database (MySQL/PgSQL) for text data. Binary data are stored to FileSystem. So far I have this functional configuration of Jackrabbit beans: <bean id="sessionFactory" class="com.example.MyJcrSessionFactory"> <constructor-arg index="0" ref="repository"/> <constructor-arg index="1" ref="jcrCredentials"/> </bean> <bean id="repository" class="org.apache.jackrabbit.core

Transaction options over Web Service calls

╄→гoц情女王★ 提交于 2019-12-21 22:47:53
问题 Does anyone have any insight into transaction options available over web-service calls? 1.) There are two applications that we have that need transactional communication between them. 2.) App1 calls a web service on app 2 and then makes some changes to its own db. the call on app2 and the changes to it's own db need to be co-ordinated. How can we do this? what are the possible options ? 回答1: You make the webservice call and if its successful do change in your own DB. If changing your own DB

How JTA/JTS handle transaction time out issue?

[亡魂溺海] 提交于 2019-12-21 20:49:07
问题 Below is my understand that JTA/ JTS handle transaction time out issue. But I cannot find my document or material to back my understand. Is my understand right? Do u know any material is refer to this issue? Application Server iterates through all the transactions to check timeout. If a transaction timeout occurs, application server marks roll back for the transaction, and log down the detail. But Application Server neither throws exception nor interrupts the transaction this moment. When the

SqlDependency subscription not working when using IsolationLevel.ReadUncommitted in (unrelated?) Transaction

余生颓废 提交于 2019-12-21 20:39:03
问题 I've managed to get SqlDependency working, but only as long as I do not use IsolationLevel.ReadUncommited in what I thought was a SQL transaction unrelated to the SqlDependency. When I use IsolationLevel.ReadUncommitted in the transaction (heavily commented below) the SqlDependency subscription fails with an immediate OnChange notification of: sqlNotificationEventArgs.Info = "Isolation"; sqlNotificationEventArgs.Source = "Statement"; sqlNotificationEventArgs.Type = "Subscribe"; When I remove