if (jpaVendorAdapter != null) { if (this.persistenceProvider == null) { this.persistenceProvider = jpaVendorAdapter.getPersistenceProvider(); Map<String, ?> vendorPropertyMap = (pui != null ? jpaVendorAdapter.getJpaPropertyMap(pui) : jpaVendorAdapter.getJpaPropertyMap()); if (!CollectionUtils.isEmpty(vendorPropertyMap)) { vendorPropertyMap.forEach((key, value) -> { this.entityManagerFactoryInterface = jpaVendorAdapter.getEntityManagerFactoryInterface(); if (!ClassUtils.isVisible(this.entityManagerFactoryInterface, this.beanClassLoader)) { this.entityManagerFactoryInterface = EntityManagerFactory.class; this.entityManagerInterface = jpaVendorAdapter.getEntityManagerInterface(); if (!ClassUtils.isVisible(this.entityManagerInterface, this.beanClassLoader)) { this.entityManagerInterface = EntityManager.class; this.jpaDialect = jpaVendorAdapter.getJpaDialect();
private EntityManagerFactory buildNativeEntityManagerFactory() { EntityManagerFactory emf; try { emf = createNativeEntityManagerFactory(); } catch (PersistenceException ex) { if (ex.getClass() == PersistenceException.class) { // Plain PersistenceException wrapper for underlying exception? // Make sure the nested exception message is properly exposed, // along the lines of Spring's NestedRuntimeException.getMessage() Throwable cause = ex.getCause(); if (cause != null) { String message = ex.getMessage(); String causeString = cause.toString(); if (!message.endsWith(causeString)) { throw new PersistenceException(message + "; nested exception is " + causeString, cause); } } } throw ex; } JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { jpaVendorAdapter.postProcessEntityManagerFactory(emf); } if (logger.isInfoEnabled()) { logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'"); } return emf; }
if (jpaVendorAdapter != null) { if (this.persistenceProvider == null) { this.persistenceProvider = jpaVendorAdapter.getPersistenceProvider(); this.entityManagerFactoryInterface = jpaVendorAdapter.getEntityManagerFactoryInterface(); if (!ClassUtils.isVisible(this.entityManagerFactoryInterface, this.beanClassLoader)) { this.entityManagerFactoryInterface = EntityManagerFactory.class; this.entityManagerInterface = jpaVendorAdapter.getEntityManagerInterface(); if (!ClassUtils.isVisible(this.entityManagerInterface, this.beanClassLoader)) { this.entityManagerInterface = EntityManager.class;
@Override public void afterPropertiesSet() throws PersistenceException { PersistenceUnitManager managerToUse = this.persistenceUnitManager; if (this.persistenceUnitManager == null) { this.internalPersistenceUnitManager.afterPropertiesSet(); managerToUse = this.internalPersistenceUnitManager; } this.persistenceUnitInfo = determinePersistenceUnitInfo(managerToUse); JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null && this.persistenceUnitInfo instanceof SmartPersistenceUnitInfo) { String rootPackage = jpaVendorAdapter.getPersistenceProviderRootPackage(); if (rootPackage != null) { ((SmartPersistenceUnitInfo) this.persistenceUnitInfo).setPersistenceProviderPackageName(rootPackage); } } super.afterPropertiesSet(); }
/** * Return a Map of vendor-specific JPA properties for the given persistence * unit, typically based on settings in this JpaVendorAdapter instance. * <p>Note that there might be further JPA properties defined on the * EntityManagerFactory bean, which might potentially override individual * JPA property values specified here. * <p>This implementation delegates to {@link #getJpaPropertyMap()} for * non-unit-dependent properties. Effectively, this PersistenceUnitInfo-based * variant only needs to be implemented if there is an actual need to react * to unit-specific characteristics such as the transaction type. * <p><b>NOTE:</b> This variant will only be invoked in case of Java EE style * container bootstrapping where a {@link PersistenceUnitInfo} is present * (i.e. {@link LocalContainerEntityManagerFactoryBean}. In case of simple * Java SE style bootstrapping via {@link javax.persistence.Persistence} * (i.e. {@link LocalEntityManagerFactoryBean}), the parameter-less * {@link #getJpaPropertyMap()} variant will be called directly. * @param pui the PersistenceUnitInfo for the current persistence unit * @return a Map of JPA properties, as accepted by the standard JPA bootstrap * facilities, or an empty Map if there are no properties to expose * @since 4.3.13 * @see PersistenceUnitInfo#getTransactionType() * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map) */ default Map<String, ?> getJpaPropertyMap(PersistenceUnitInfo pui) { return getJpaPropertyMap(); }
public PlatformTransactionManager getSpringPlatformTransactionManager(Object testObject) { EntityManagerFactory entityManagerFactory = getPersistenceUnit(testObject); JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(entityManagerFactory); jpaTransactionManager.setDataSource(getDataSource()); jpaTransactionManager.setJpaDialect(jpaProviderSupport.getSpringJpaVendorAdaptor().getJpaDialect()); return jpaTransactionManager; }
@Override public void afterPropertiesSet() throws PersistenceException { PersistenceUnitManager managerToUse = this.persistenceUnitManager; if (this.persistenceUnitManager == null) { this.internalPersistenceUnitManager.afterPropertiesSet(); managerToUse = this.internalPersistenceUnitManager; } this.persistenceUnitInfo = determinePersistenceUnitInfo(managerToUse); JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null && this.persistenceUnitInfo instanceof SmartPersistenceUnitInfo) { String rootPackage = jpaVendorAdapter.getPersistenceProviderRootPackage(); if (rootPackage != null) { ((SmartPersistenceUnitInfo) this.persistenceUnitInfo).setPersistenceProviderPackageName(rootPackage); } } super.afterPropertiesSet(); }
/** * Return a Map of vendor-specific JPA properties for the given persistence * unit, typically based on settings in this JpaVendorAdapter instance. * <p>Note that there might be further JPA properties defined on the * EntityManagerFactory bean, which might potentially override individual * JPA property values specified here. * <p>This implementation delegates to {@link #getJpaPropertyMap()} for * non-unit-dependent properties. Effectively, this PersistenceUnitInfo-based * variant only needs to be implemented if there is an actual need to react * to unit-specific characteristics such as the transaction type. * <p><b>NOTE:</b> This variant will only be invoked in case of Java EE style * container bootstrapping where a {@link PersistenceUnitInfo} is present * (i.e. {@link LocalContainerEntityManagerFactoryBean}. In case of simple * Java SE style bootstrapping via {@link javax.persistence.Persistence} * (i.e. {@link LocalEntityManagerFactoryBean}), the parameter-less * {@link #getJpaPropertyMap()} variant will be called directly. * @param pui the PersistenceUnitInfo for the current persistence unit * @return a Map of JPA properties, as accepted by the standard JPA bootstrap * facilities, or an empty Map if there are no properties to expose * @since 4.3.13 * @see PersistenceUnitInfo#getTransactionType() * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map) */ default Map<String, ?> getJpaPropertyMap(PersistenceUnitInfo pui) { return getJpaPropertyMap(); }
if (jpaVendorAdapter != null) { if (this.persistenceProvider == null) { this.persistenceProvider = jpaVendorAdapter.getPersistenceProvider(); Map<String, ?> vendorPropertyMap = (pui != null ? jpaVendorAdapter.getJpaPropertyMap(pui) : jpaVendorAdapter.getJpaPropertyMap()); if (!CollectionUtils.isEmpty(vendorPropertyMap)) { vendorPropertyMap.forEach((key, value) -> { this.entityManagerFactoryInterface = jpaVendorAdapter.getEntityManagerFactoryInterface(); if (!ClassUtils.isVisible(this.entityManagerFactoryInterface, this.beanClassLoader)) { this.entityManagerFactoryInterface = EntityManagerFactory.class; this.entityManagerInterface = jpaVendorAdapter.getEntityManagerInterface(); if (!ClassUtils.isVisible(this.entityManagerInterface, this.beanClassLoader)) { this.entityManagerInterface = EntityManager.class; this.jpaDialect = jpaVendorAdapter.getJpaDialect();
@Override public void afterPropertiesSet() throws PersistenceException { PersistenceUnitManager managerToUse = this.persistenceUnitManager; if (this.persistenceUnitManager == null) { this.internalPersistenceUnitManager.afterPropertiesSet(); managerToUse = this.internalPersistenceUnitManager; } this.persistenceUnitInfo = determinePersistenceUnitInfo(managerToUse); JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null && this.persistenceUnitInfo instanceof SmartPersistenceUnitInfo) { String rootPackage = jpaVendorAdapter.getPersistenceProviderRootPackage(); if (rootPackage != null) { ((SmartPersistenceUnitInfo) this.persistenceUnitInfo).setPersistenceProviderPackageName(rootPackage); } } super.afterPropertiesSet(); }
props.putAll(factory.getJpaVendorAdapter().getJpaPropertyMap()); props.putAll(factory.getJpaPropertyMap());
private EntityManagerFactory buildNativeEntityManagerFactory() { EntityManagerFactory emf; try { emf = createNativeEntityManagerFactory(); } catch (PersistenceException ex) { if (ex.getClass() == PersistenceException.class) { // Plain PersistenceException wrapper for underlying exception? // Make sure the nested exception message is properly exposed, // along the lines of Spring's NestedRuntimeException.getMessage() Throwable cause = ex.getCause(); if (cause != null) { String message = ex.getMessage(); String causeString = cause.toString(); if (!message.endsWith(causeString)) { throw new PersistenceException(message + "; nested exception is " + causeString, cause); } } } throw ex; } JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { jpaVendorAdapter.postProcessEntityManagerFactory(emf); } if (logger.isInfoEnabled()) { logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'"); } return emf; }
private EntityManagerFactory buildNativeEntityManagerFactory() { EntityManagerFactory emf; try { emf = createNativeEntityManagerFactory(); } catch (PersistenceException ex) { if (ex.getClass() == PersistenceException.class) { // Plain PersistenceException wrapper for underlying exception? // Make sure the nested exception message is properly exposed, // along the lines of Spring's NestedRuntimeException.getMessage() Throwable cause = ex.getCause(); if (cause != null) { String message = ex.getMessage(); String causeString = cause.toString(); if (!message.endsWith(causeString)) { throw new PersistenceException(message + "; nested exception is " + causeString, cause); } } } throw ex; } JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { jpaVendorAdapter.postProcessEntityManagerFactory(emf); } if (logger.isInfoEnabled()) { logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'"); } return emf; }