private EntityManagerFactory createEntityManagerFactory() { Assertions.assertThat(persistenceUnitContextManager.isValidPersistenceUnit(persistenceUnitName)) .as("Not a valid persistence unit: %s", persistenceUnitName) .isTrue(); final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setPersistenceUnitManager(persistenceUnitManager); factory.setPersistenceUnitName(persistenceUnitName); final JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { factory.setJpaVendorAdapter(jpaVendorAdapter); } else { factory.setPersistenceProvider(getPersistenceProvider()); } final JpaDialect jpaDialect = getJpaDialect(); if (jpaDialect != null) { factory.setJpaDialect(jpaDialect); } factory.afterPropertiesSet(); final String entityManagerFactoryBeanName = getPersistenceUnitName() + PersistenceProperties.ENTITY_MANAGER_FACTORY_NAME_SUFFIX; MergedContext.getInstance().registerBean(entityManagerFactoryBeanName, factory); Assertions.assertThat(MergedContext.getInstance().getBean(entityManagerFactoryBeanName)).isNotNull(); return factory.getObject(); }
@Bean @Autowired public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { JpaTransactionManager txManager = new JpaTransactionManager(); JpaDialect jpaDialect = new HibernateJpaDialect(); txManager.setEntityManagerFactory(entityManagerFactory); txManager.setJpaDialect(jpaDialect); return txManager; }
private PlatformTransactionManager createTransactionManager() { final JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(); jpaTransactionManager.setEntityManagerFactory(getEntityManagerFactory()); final JpaDialect jpaDialect = getJpaDialect(); if (jpaDialect != null) { jpaTransactionManager.setJpaDialect(jpaDialect); } final LoggingDelegateTransactionManager loggingDelegateTransactionManager = new LoggingDelegateTransactionManager( this, jpaTransactionManager); final String transactionManagerBeanName = getPersistenceUnitName() + PersistenceProperties.TRANSACTION_MANAGER_NAME_SUFFIX; MergedContext.getInstance().registerBean(transactionManagerBeanName, loggingDelegateTransactionManager); Assertions.assertThat(MergedContext.getInstance().getBean(transactionManagerBeanName)).isNotNull(); return loggingDelegateTransactionManager; }
@Bean @Autowired public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { JpaDialect jpaDialect = new HibernateJpaDialect(); JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory); txManager.setJpaDialect(jpaDialect); return txManager; }
public final void afterPropertiesSet() { EntityManagerFactory emf = getEntityManagerFactory(); if (emf == null) { throw new IllegalArgumentException("'entityManagerFactory' or 'persistenceUnitName' is required"); } Class[] ifcs = null; if (emf instanceof EntityManagerFactoryInfo) { EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf; if (this.entityManagerInterface == null) { this.entityManagerInterface = emfInfo.getEntityManagerInterface(); if (this.entityManagerInterface == null) { this.entityManagerInterface = EntityManager.class; } } JpaDialect jpaDialect = emfInfo.getJpaDialect(); if (jpaDialect != null && jpaDialect.supportsEntityManagerPlusOperations()) { ifcs = new Class[] {this.entityManagerInterface, EntityManagerPlus.class}; } else { ifcs = new Class[] {this.entityManagerInterface}; } } else { if (this.entityManagerInterface == null) { this.entityManagerInterface = EntityManager.class; } ifcs = new Class[] {this.entityManagerInterface}; } this.shared = SharedEntityManagerCreator.createSharedEntityManager(emf, getJpaPropertyMap(), ifcs); }
@Bean @Autowired public JpaTransactionManager transactionManager(EntityManagerFactory emf, JpaDialect dialect) { JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(emf); txManager.setJpaDialect(dialect); return txManager; }
@Override public JpaDialect getJpaDialect() { return this.jpaDialect; }
@Override public JpaDialect getJpaDialect() { return null; }
public JpaDialect customJpaDialect() { return new CustomHibernateJpaDialect(); }
@Override public JpaDialect getJpaDialect(final PersistenceUnitContext persistenceUnitContext) { return null; }
private JpaDialect getJpaDialect() { return persistenceUnitContextManager.getDialectSpecificDelegate(getConnectionDialect()).getJpaDialect(this); }
@Override public JpaDialect getJpaDialect(final PersistenceUnitContext persistenceUnitContext) { return new HibernateExtendedJpaDialect(); }
public JpaDialect getJpaDialect() { return null; }
/** * Initializes the hypersonic db. */ public synchronized void init(String... packagesToScan) { if (ArrayUtils.isEmpty(packagesToScan)) { throw new RuntimeException("Package names to scan must be provided as arg"); } if (isInitialized()) { //If already initialized just return cleanly return; } try { dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUrl("jdbc:hsqldb:mem:sprite"); dataSource.setUsername("sa"); dataSource.setPassword(""); JpaDialect dialect = new HibernateJpaDialect(); LocalContainerEntityManagerFactoryBean localEMFactory = new LocalContainerEntityManagerFactoryBean(); localEMFactory.setJpaDialect(dialect); localEMFactory.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); localEMFactory.setDataSource(dataSource); localEMFactory.setPackagesToScan(packagesToScan); //localEMFactory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("eclipselink.logging.level", "FINE"); properties.put("eclipselink.logging.level.sql", "FINE"); properties.put("hibernate.hbm2ddl.auto", "create-drop"); properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); properties.put("PersistenceVersion", "2.1"); localEMFactory.setJpaPropertyMap(properties); localEMFactory.afterPropertiesSet(); entityManagerFactory = localEMFactory.getObject(); jdbcTemplate = new JdbcTemplate(dataSource); transactionManager = new JpaTransactionManager(); transactionManager.setJpaDialect(dialect); transactionManager.setEntityManagerFactory(entityManagerFactory); transactionManager.setDataSource(dataSource); } catch (Exception ex) { ex.printStackTrace(); fail("Failed to initialize entityManager: " + ex); } initialized = true; }
/** * {@inheritDoc} */ @Override public JpaDialect getJpaDialect() { return internalFactoryBean.getJpaDialect(); }
@Bean public JpaDialect jpaDialect() { return new HibernateJpaDialect(); }
public JpaDialect getJpaDialect() { return this.jpaDialect; }
/** * SPI strategy that encapsulates certain functionality that standard JPA 2.1 does not offer, * such as access to the underlying JDBC Connection. * This strategy is mainly intended for standalone usage of a JPA provider. */ @Bean public JpaDialect jpaDialect() { return new EclipseLinkJpaDialect(); }
/** * May return to null to stick with default. */ JpaDialect getJpaDialect(PersistenceUnitContext persistenceUnitContext);
/** * Specify the vendor-specific JpaDialect implementation to associate with this EntityManagerFactory. * * <p> * This will be exposed through the EntityManagerFactoryInfo interface, to be picked up as default dialect by * accessors that intend to use JpaDialect functionality. * </p> * * @param jpaDialect the JPA dialect to set * * @see EntityManagerFactoryInfo#getJpaDialect() */ public void setJpaDialect(JpaDialect jpaDialect) { this.internalFactoryBean.setJpaDialect(jpaDialect); }