Example usage for org.springframework.orm.hibernate5 SpringJtaSessionContext SpringJtaSessionContext

List of usage examples for org.springframework.orm.hibernate5 SpringJtaSessionContext SpringJtaSessionContext

Introduction

In this page you can find the example usage for org.springframework.orm.hibernate5 SpringJtaSessionContext SpringJtaSessionContext.

Prototype

public SpringJtaSessionContext(SessionFactoryImplementor factory) 

Source Link

Usage

From source file:org.grails.orm.hibernate.GrailsSessionContext.java

public void initJta() {
    JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class);
    TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager();
    jtaSessionContext = transactionManager == null ? null : new SpringJtaSessionContext(sessionFactory);
}

From source file:org.springframework.orm.hibernate5.SpringSessionContext.java

/**
 * Create a new SpringSessionContext for the given Hibernate SessionFactory.
 * @param sessionFactory the SessionFactory to provide current Sessions for
 *///from   ww w.  j ava 2s.  c o m
public SpringSessionContext(SessionFactoryImplementor sessionFactory) {
    this.sessionFactory = sessionFactory;
    try {
        JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class);
        this.transactionManager = jtaPlatform.retrieveTransactionManager();
        if (this.transactionManager != null) {
            this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory);
        }
    } catch (Exception ex) {
        LogFactory.getLog(SpringSessionContext.class)
                .warn("Could not introspect Hibernate JtaPlatform for SpringJtaSessionContext", ex);
    }
}