Example usage for org.springframework.orm.jpa EntityManagerFactoryInfo getJpaDialect

List of usage examples for org.springframework.orm.jpa EntityManagerFactoryInfo getJpaDialect

Introduction

In this page you can find the example usage for org.springframework.orm.jpa EntityManagerFactoryInfo getJpaDialect.

Prototype

@Nullable
JpaDialect getJpaDialect();

Source Link

Document

Return the vendor-specific JpaDialect implementation for this EntityManagerFactory, or null if not known.

Usage

From source file:org.springframework.orm.jpa.EntityManagerFactoryUtils.java

/**
 * Prepare a transaction on the given EntityManager, if possible.
 * @param em the EntityManager to prepare
 * @param emf the EntityManagerFactory that the EntityManager has been created with
 * @return an arbitrary object that holds transaction data, if any
 * (to be passed into cleanupTransaction)
 * @see JpaDialect#prepareTransaction//w  ww  .  j  av  a2s  .  com
 */
@Nullable
private static Object prepareTransaction(EntityManager em, EntityManagerFactory emf) {
    if (emf instanceof EntityManagerFactoryInfo) {
        EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf;
        JpaDialect jpaDialect = emfInfo.getJpaDialect();
        if (jpaDialect != null) {
            return jpaDialect.prepareTransaction(em,
                    TransactionSynchronizationManager.isCurrentTransactionReadOnly(),
                    TransactionSynchronizationManager.getCurrentTransactionName());
        }
    }
    return null;
}

From source file:org.springframework.orm.jpa.EntityManagerFactoryUtils.java

/**
 * Prepare a transaction on the given EntityManager, if possible.
 * @param transactionData arbitrary object that holds transaction data, if any
 * (as returned by prepareTransaction)//from  w  ww .  ja v a  2s.c  o m
 * @param emf the EntityManagerFactory that the EntityManager has been created with
 * @see JpaDialect#cleanupTransaction
 */
private static void cleanupTransaction(@Nullable Object transactionData, EntityManagerFactory emf) {
    if (emf instanceof EntityManagerFactoryInfo) {
        EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf;
        JpaDialect jpaDialect = emfInfo.getJpaDialect();
        if (jpaDialect != null) {
            jpaDialect.cleanupTransaction(transactionData);
        }
    }
}

From source file:org.springframework.orm.jpa.ExtendedEntityManagerCreator.java

/**
 * Actually create the EntityManager proxy.
 * @param rawEntityManager raw EntityManager
 * @param emfInfo the EntityManagerFactoryInfo to obtain the JpaDialect
 * and PersistenceUnitInfo from// w w  w. j  a  va 2  s . co  m
 * @param containerManaged whether to follow container-managed EntityManager
 * or application-managed EntityManager semantics
 * @param synchronizedWithTransaction whether to automatically join ongoing
 * transactions (according to the JPA 2.1 SynchronizationType rules)
 * @return the EntityManager proxy
 */
private static EntityManager createProxy(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo,
        boolean containerManaged, boolean synchronizedWithTransaction) {

    Assert.notNull(emfInfo, "EntityManagerFactoryInfo must not be null");
    JpaDialect jpaDialect = emfInfo.getJpaDialect();
    PersistenceUnitInfo pui = emfInfo.getPersistenceUnitInfo();
    Boolean jta = (pui != null ? pui.getTransactionType() == PersistenceUnitTransactionType.JTA : null);
    return createProxy(rawEntityManager, emfInfo.getEntityManagerInterface(), emfInfo.getBeanClassLoader(),
            jpaDialect, jta, containerManaged, synchronizedWithTransaction);
}