Example usage for org.springframework.orm.jpa.vendor EclipseLinkJpaDialect setLazyDatabaseTransaction

List of usage examples for org.springframework.orm.jpa.vendor EclipseLinkJpaDialect setLazyDatabaseTransaction

Introduction

In this page you can find the example usage for org.springframework.orm.jpa.vendor EclipseLinkJpaDialect setLazyDatabaseTransaction.

Prototype

public void setLazyDatabaseTransaction(boolean lazyDatabaseTransaction) 

Source Link

Document

Set whether to lazily start a database resource transaction within a Spring-managed EclipseLink transaction.

Usage

From source file:com.peertopark.spring.data.SpringDataConfig.java

@Bean
public JpaDialect jpaDialect() {
    EclipseLinkJpaDialect jpaDialect = new EclipseLinkJpaDialect();
    jpaDialect.setLazyDatabaseTransaction(true);
    return jpaDialect;
}

From source file:cz.lbenda.coursing.client.ClientAppConfig.java

public @Bean EntityManagerFactory entityManagerFactory() {
    try {// ww w .j a v a  2s.co m
        EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
        vendorAdapter.setDatabasePlatform("org.eclipse.persistence.platform.database.H2Platform");
        vendorAdapter.setShowSql(true);
        vendorAdapter.setGenerateDdl(true);
        EclipseLinkJpaDialect dialect = new EclipseLinkJpaDialect();
        dialect.setLazyDatabaseTransaction(true);

        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setJpaVendorAdapter(vendorAdapter);
        factory.setJpaDialect(dialect);
        factory.setPackagesToScan("cz.lbenda.coursing");
        factory.setDataSource(dataSource());
        factory.setPersistenceXmlLocation("classpath*:META-INF/persistence.xml");
        factory.setPersistenceUnitName("coursing");

        /*
        Map<String, String> prop = new HashMap<>();
        prop.put("eclipselink.deploy-on-startup", "true");
        prop.put("eclipselink.ddl-generation", "create-or-extend-tables");
        prop.put("eclipselink.ddl-generation.output-mode", "database");
        prop.put("eclipselink.create-ddl-jdbc-file-name", "create.sql");
        prop.put("eclipselink.weaving", "static");
        prop.put("eclipselink.weaving.lazy", "true");
        prop.put("eclipselink.weaving.internal", "true");
        prop.put("eclipselink.logging.level", "SEVERE");
        prop.put("eclipselink.query-results-cache.type", "WEAK");
        prop.put("eclipselink.jdbc.batch-writing", "JDBC");
        prop.put("eclipselink.jdbc.batch-writing.size", "1000");
                
        factory.setJpaPropertyMap(prop);
        */

        // factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
        factory.afterPropertiesSet();

        return factory.getObject();
    } catch (Exception e) {
        LOG.trace("Faild create entityManagerFactory", e);
        throw new RuntimeException("Faild create entityManagerFactory", e);
    }
}