/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2011, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.as.jpa.hibernate;


import javax.transaction.TransactionManager;

import org.jboss.as.jpa.transaction.TransactionUtil;


/**
 * @author Steve Ebersole
 */
public class JBossAppServerJtaPlatform extends org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform {
    @Override
    protected boolean canCacheTransactionManager() {
        return true;
    }

    @Override
    protected TransactionManager locateTransactionManager() {
        return TransactionUtil.getTransactionManager();
    }

}

@@ -1065,254 +1065,1047 @@
 ort 
-javax.transaction.TransactionManager;%0A%0Aimport org.jboss.as.jpa.transaction.TransactionUtil;%0A%0A%0A/**%0A * @author Steve Ebersole%0A */%0Apublic class JBossAppServerJtaPlatform extends org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform %7B
+org.hibernate.service.jta.platform.internal.JtaSynchronizationStrategy;%0Aimport org.hibernate.service.jta.platform.internal.SynchronizationRegistryAccess;%0Aimport org.hibernate.service.jta.platform.internal.SynchronizationRegistryBasedSynchronizationStrategy;%0Aimport org.jboss.as.jpa.transaction.TransactionUtil;%0A%0Aimport javax.transaction.TransactionManager;%0Aimport javax.transaction.TransactionSynchronizationRegistry;%0A%0A%0A/**%0A * @author Steve Ebersole%0A */%0Apublic class JBossAppServerJtaPlatform extends org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform %7B%0A%0A    private final JtaSynchronizationStrategy synchronizationStrategy;%0A%0A    public JBossAppServerJtaPlatform() %7B%0A        this.synchronizationStrategy =  new SynchronizationRegistryBasedSynchronizationStrategy(new SynchronizationRegistryAccess() %7B%0A            @Override%0A            public TransactionSynchronizationRegistry getSynchronizationRegistry() %7B%0A                return TransactionUtil.getTransactionSynchronizationRegistry();%0A            %7D%0A        %7D);%0A    %7D%0A
 %0A   
@@ -2335,10 +2335,142 @@
 %0A    %7D%0A%0A
+    @Override%0A    protected JtaSynchronizationStrategy getSynchronizationStrategy() %7B%0A        return synchronizationStrategy;%0A    %7D%0A
 %7D%0A

Make sure the Hibernate flush() synchronization runs after all other synchronizations