Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315783

Summary: Setting connection auto commit incorrectly
Product: z_Archived Reporter: steve
Component: EclipselinkAssignee: Project Inbox <eclipselink.foundation-inbox>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P2 CC: steve, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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