transactions

Should I commit or rollback a read transaction?

I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do? Commit the transaction Rollback the transaction Do nothing (which will cause the transaction to be rolled back at the end of the using block) What are the implications of doing each? usin...

Sql Transactions: Best Way to Implement in ASP.Net

I have an application that has many different types of objects that each persist themselves back to the db. This has worked fine so far without transactions and I'm not looking to go hog wild adding them. But there is an occasional need to start a transaction before a whole collection of the objects start updating to ensure that the data...

Connections will not close when using Transaction Binding=Explicit Unbind; in connection string

I´m using Transaction Binding=Explicit Unbind in the connection string as recommended here since I´m also using TransactionScope with timeout. The problem is that the connections does not seem to close after being disposed and eventually there are no more connections available in the connection pool. I got the same result when I modified...

How can I confirm NHibernate is actually using a transaction using SQL Profiler?

I am using the following generic code to save entities. using (ITransaction tx = session.BeginTransaction()) { try { entity.DateModified = DateTime.Now; session.SaveOrUpdate(entity); session.Flush(); tx.Commit(); return entity; } catch (Exception) { tx.Rollback(); thro...

How to Get Last Created Entry's ID From Sql Database With Asp.Net

I will explain problem with an example: There is two table in my database, named entry, tags There is a column named ID_ENTRY in both table. When I add a record to table, entry, I have to take the ID_ENTRY of last added record and add it to table, tags. How can I do it? ...

system transaction .net remove exception from session

Hi I am new to asp.net. I am working on an application that is doing system transactions. At some point in code an exception is raised and the code bombs out. It bombs out when clicking on a particular row record in a grid list. However after the user sees the exception...they go back and try to click some other record..which should ...

mysqli->error: Is it for the last query only, or for the last error from the query group?

Hi All, I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query. Is this a decent practice or should I be checking for the error in between every query? Thanks! $mysqli->autocommit(FALSE); $mysqli->query("INSERT INTO ........

How do detect that transaction has already been started?

I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started? Here is a sample bit of code: try { ...

Django: How can I protect against concurrent modification of data base entries

If there a way to protect against concurrent modifications of the same data base entry by two or more users? It would be acceptable to show an error message to the user performing the second commit/save operation, but data should not be silently overwritten. I think locking the entry is not an option, as a user might use the "Back" but...

TransactionScope Error against Sql Server 2000 - The partner transaction manager has disabled its support for remote/network transactions.

I am trying to set up a simple transaction for my Linq-to-Sql actions against my Sql 2000 database. Using TransactionScope it looks like this: using (TransactionScope transaction = new TransactionScope()) { try { Store.DBDataContext dc = new Store.DBDataContext(); Store.Product product = GetProduct("foo"); dc...

How are EJB3 transactions propgated over multiple session beans?

I've read the EJB3 spec and the latest O'Reilly and Manning books and yet I can't see defined anywhere how transactions are propagated over multiple session beans. For example, if I call a method marked as "NEVER" on bean A and bean A calls a method marked as REQUIRESNEW on bean B, what happens? In practice, using JBoss, we've observed...

Transaction with MonetDB and JDBC driver

I'm trying to perform transaction-like behavior with MonetDB and its JDBC driver. I tried first to set autocommit to false for the connection, I then get the following error on commit : java.lang.IndexOutOfBoundsException at java.nio.StringCharBuffer.subSequence(StringCharBuffer.java:92) at nl.cwi.monetdb.mcl.parser.StartOfHead...

.NET equivalent of modern Java web architecture

Almost every new Java-web-project is using a modern MVC-framework such as Struts or Spring MVC for the web tier, Spring for the "Service"/business-logic-layer and an ORM mapper such as Hibernate for persistence. What is the equivalent in .NET? I guess ASP.NET is used for the web tier and ADO.NET for persistence but what is the equivale...

Hibernate and Spring transactions - using private constructors/static factory methods

We have a Hibernate/Spring application that have the following Spring beans: <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" /> When wiring the application together we get...

TransactionScope not rolling back transaction

Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong? EDIT: I removed the try/catch from insert2 and insert3. I also removed the exception handling utility from the ins...

How do I ensure a value being updated with Hibernate hadn't been changed in the meantime since I read it?

I have a problem where I want to read an object from the database using Hibernate, change a value, and save the object. If changing the value takes some time, what's the best way to ensure the underlying object in the database has not changed? I am doing this in one transaction (and one session). The code looks something like: // Load...

System.Transaction implicit transaction messing with my other connections

I'm trying to use System.Transaction.TransactionScope to create a transaction to call a few stored procedures but it doesn't seem to clean up after itself. Once the transaction is finished (commited or not and the transaction scope object is disposed) subsequent connections to the database open up with the read commit level of serializab...

ADO.NET check if Rollback is possible

I'm asking myself if it is possible to check if in ADO.NET the current transaction can be rolled back. The msdn suggests the following implementation: private static void ExecuteSqlTransaction(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); ...

AOP problem running Spring unit tests

I have a Spring web application which is configured to use JDK proxying for AOP. The AOP annotations (such as @Transactional) are declared on the interfaces, rather than the implementation classes. The application itself works fine, but when I run the unit tests, it seems to be attempting to use CGLIB for the AOP functionality (instead ...

Rails transactions

Trying to use ActiveRecord::Base.transaction I figured that rollback doesn't work by default using Rails 1.2.6 and mysql 5.0. Playing with it a little bit more I found out that autocommit is not set to 0 in mysql connection. Questions: 1) how do I disable autocommit in rails for all connections 2) will it have some negative impact on...