[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-6651) performing SchemExport within JTA/Managed transaction leads to error attempting to set auto-commit

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Sep 14 15:12:02 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-6651.
-------------------------------

       Resolution: Rejected
    Fix Version/s:     (was: 4.0.0.CR3)

The difficulty here is that performing schema export during an existing JTA transaction will be problematic on many databases which implicitly commit transactions on DDL statement execution (CREATE, ALTER, etc).

The real solution is to suspend this transaction prior to attempting to build the {{SessionFactory}}/{{EntityManagerFactory}} with schema exporting enabled.  We could definitely attempt to add this behavior to Hibernate at some point, but that moves into the realm of an enhancement request as opposed to a bug.

> performing SchemExport within JTA/Managed transaction leads to error attempting to set auto-commit
> --------------------------------------------------------------------------------------------------
>
>                 Key: HHH-6651
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6651
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 4.0.0.CR2
>            Reporter: Scott Marlow
>            Assignee: Steve Ebersole
>
> Calling javax.persistence.Persistence.createEntityManagerFactory with an active JTA transaction, can lead to "HHH00231:Schema export unsuccessful: java.sql.SQLException: You cannot set autocommit during a managed transaction!"
> The is with a Persistence unit with transaction_type = JTA (the problem doesn't occur if transaction_type = RESOURCE_LOCAL since the JTA transaction is ignored for that).
> I created a AS7 unit test here if that is helpful.  https://github.com/scottmarlow/jboss-as/tree/bootstrap is the branch and https://github.com/scottmarlow/jboss-as/commit/f181d5e919c64d62b1e8ab5e455929159331d922 contains the change.
> The user forum report is here http://community.jboss.org/message/626226 (be careful reading because the wrong exception is pasted a few times).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list