Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315783 - Setting connection auto commit incorrectly
Summary: Setting connection auto commit incorrectly
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 11:15 EDT by steve CLA
Modified: 2022-06-09 10:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description steve CLA 2010-06-04 11:15:02 EDT
Build Identifier: 1.1.2

Starting with a db connection with auto commit to false gets turned back on to true in DatabaseAccessor.basicCommitTransaction method. 

Our platform supports auto commit but in many cases we turn the auto commit to false on some connections since the code requires multiple sql statements to be in the same transaction. We noticed that when we have a db connection auto commit set to false and we do a commit, the connection's auto commit gets set back to true thus changing the state of the original connection.

    /**
     * Commit a transaction on the database. This means toggling the auto-commit option.
     */
    public void basicCommitTransaction(AbstractSession session) throws DatabaseException {
        try {
            if (getPlatform().supportsAutoCommit()) {
                getConnection().commit();
                getConnection().setAutoCommit(true);
            } else {
                getPlatform().commitTransaction(this);
            }
        } catch (SQLException exception) {
            DatabaseException commException = processExceptionForCommError(session, exception, null);
            if (commException != null) throw commException;
            throw DatabaseException.sqlException(exception, this, session, false);
        }
    }

Couldn't the code save the original state and set it back to what it was in the first place?

Reproducible: Always
Comment 1 Tom Ware CLA 2010-06-14 14:27:17 EDT
Setting target and priority.  See the following page for details of what these fields mean:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:10:36 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:15:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink