Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
- <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- ...
- <property name="jpaPropertyMap">
- <map>
- <entry key="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE" />
- </map>
- </property>
- </bean>
- <shared-cache-mode>
- @Bean
- public EntityManagerFactory entityManagerFactory() {
- LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
- factory.setDataSource(dataSource());
- factory.setPersistenceUnitName("main");
- final EclipseLinkJpaDialect customDialect = new EclipseLinkJpaDialect() {
- @Override
- public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException {
- // Hides: return super.getJdbcConnection(entityManager, readOnly);
- // IMPORTANT LINE
- return null;
- }
- };
- // IMPORTANT LINE
- customDialect.setLazyDatabaseTransaction(true);
- EclipseLinkJpaVendorAdapter customAdapter = new EclipseLinkJpaVendorAdapter() {
- @Override
- public JpaDialect getJpaDialect() {
- return customDialect;
- }
- };
- customAdapter.setDatabase(Database.ORACLE);
- factory.setJpaVendorAdapter(customAdapter);
- factory.afterPropertiesSet();
- return factory.getObject();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement