/** * @return EntityManager Factory */ @Bean(name = "entityManagerFactoryEcandidat") public LocalContainerEntityManagerFactoryBean entityManagerFactoryEcandidat() { DataSource ds = dataSourceEcandidat(); /* Si l'appli s'initialise, il faut lancer Flyway */ /** * TODO:problème avec tomcat8 qui reinitialise les beans au shutdown et met * flyway en erreur */ String init = System.getProperty(ConstanteUtils.STARTUP_INIT_FLYWAY); if (init == null || !init.equals(ConstanteUtils.STARTUP_INIT_FLYWAY_OK)) { initFlyway(ds); System.setProperty(ConstanteUtils.STARTUP_INIT_FLYWAY, ConstanteUtils.STARTUP_INIT_FLYWAY_OK); } LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); localContainerEntityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); localContainerEntityManagerFactoryBean.setPackagesToScan(Candidat.class.getPackage().getName(), LocalTimePersistenceConverter.class.getPackage().getName()); localContainerEntityManagerFactoryBean.setDataSource(ds); localContainerEntityManagerFactoryBean.setJpaDialect(new EclipseLinkJpaDialect()); Properties jpaProperties = new Properties(); /* Active le static weaving d'EclipseLink */ jpaProperties.put(PersistenceUnitProperties.WEAVING, "static"); /* Désactive le cache partagé */ jpaProperties.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT, String.valueOf(false)); localContainerEntityManagerFactoryBean.setJpaProperties(jpaProperties); EclipseLinkJpaVendorAdapter jpaVendorAdapter = new EclipseLinkJpaVendorAdapter(); jpaVendorAdapter.setGenerateDdl(false); jpaVendorAdapter.setShowSql(false); localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter); return localContainerEntityManagerFactoryBean; }
@Override protected AbstractJpaVendorAdapter createJpaVendorAdapter() { return new EclipseLinkJpaVendorAdapter() { private final HawkBitEclipseLinkJpaDialect jpaDialect = new HawkBitEclipseLinkJpaDialect(); @Override public EclipseLinkJpaDialect getJpaDialect() { return jpaDialect; } }; }
@Override public EclipseLinkJpaDialect getJpaDialect() { return jpaDialect; }
@Bean public EclipseLinkJpaDialect eclipseLinkJpaDialect() { return new EclipseLinkJpaDialect(); }
/** * 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(); }