Java Code Examples for org.springframework.orm.jpa.JpaTransactionManager#setEntityManagerFactory()

The following examples show how to use org.springframework.orm.jpa.JpaTransactionManager#setEntityManagerFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() throws SQLException {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(entityManagerFactory());
    jpaTransactionManager.afterPropertiesSet();
    return jpaTransactionManager;
}
 
Example 2
Source File: DatabaseConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() throws SQLException {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(entityManagerFactory());
    jpaTransactionManager.afterPropertiesSet();
    return jpaTransactionManager;
}
 
Example 3
Source File: FileConversionServiceTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public PlatformTransactionManager jpaTransactionManager() {

    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}
 
Example 4
Source File: PersistanceConfig.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Transaction manager.
 *
 * @return the platform transaction manager
 */
@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager tm = new JpaTransactionManager();
    tm.setEntityManagerFactory(this.entityManagerFactory().getObject());
    return tm;
}
 
Example 5
Source File: DatabaseConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() throws SQLException {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(entityManagerFactory());
    jpaTransactionManager.afterPropertiesSet();
    return jpaTransactionManager;
}
 
Example 6
Source File: RenditionsConfig.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return txManager;
}
 
Example 7
Source File: RadiusDbConfiguration.java    From radman with MIT License 4 votes vote down vote up
@Bean(name = "txRadius")
PlatformTransactionManager radiusTransactionManager() {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(radiusEntityManager().getObject());
    return transactionManager;
}
 
Example 8
Source File: HibernateConfig.java    From logging-log4j-audit with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(entityManagerFactory());
    return txManager;
}
 
Example 9
Source File: JpaConfig.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	JpaTransactionManager txManager = new JpaTransactionManager();
	txManager.setEntityManagerFactory(entityManagerFactory().getObject());
	return txManager;
}
 
Example 10
Source File: JPAStartupService.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Initialize JPA objects (Datasource, Persistence Unit Manager, Entity Manager Factory, Transaction Manager) for each pool.
 */
public void process( )
{
    ReferenceList list = new ReferenceList( );
    AppConnectionService.getPoolList( list );

    Map<String, EntityManagerFactory> mapFactories = new HashMap<>( );
    List<PlatformTransactionManager> listTransactionManagers = new ArrayList<>( );
    _log.info( "JPA Startup Service : Initializing JPA objects ..." );

    String strDialectProperty = AppPropertiesService.getProperty( JPA_DIALECT_PROPERTY );

    for ( ReferenceItem poolItem : list )
    {
        String strPoolname = poolItem.getCode( );

        DataSource ds = AppConnectionService.getPoolManager( ).getDataSource( strPoolname );
        _log.info( "JPA Startup Service : DataSource retrieved for pool : " + strPoolname );
        _log.debug( "> DS : " + ds.toString( ) );

        DefaultPersistenceUnitManager pum = new DefaultPersistenceUnitManager( );
        pum.setDefaultDataSource( ds );

        PersistenceUnitPostProcessor [ ] postProcessors = {
                new JPAPersistenceUnitPostProcessor( )
        };
        pum.setPersistenceUnitPostProcessors( postProcessors );

        pum.afterPropertiesSet( );

        _log.info( "JPA Startup Service : Persistence Unit Manager for pool : " + strPoolname );
        _log.debug( "> PUM : " + pum.toString( ) );

        LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean( );
        lcemfb.setDataSource( ds );
        lcemfb.setPersistenceUnitManager( pum );
        lcemfb.setPersistenceUnitName( "jpaLuteceUnit" );

        JpaDialect jpaDialect = SpringContextService.getBean( "jpaDialect" );
        lcemfb.setJpaDialect( jpaDialect );

        Map mapJpaProperties = SpringContextService.getBean( "jpaPropertiesMap" );
        lcemfb.setJpaPropertyMap( mapJpaProperties );

        String strDialect = AppPropertiesService.getProperty( poolItem.getName( ) + ".dialect" );

        // replace default dialect if <poolname>.dialect is specified
        if ( StringUtils.isNotBlank( strDialect ) )
        {
            mapJpaProperties.put( strDialectProperty, strDialect );
        }

        _log.debug( "Using dialect " + mapJpaProperties.get( strDialectProperty ) + " for pool " + poolItem.getName( ) );

        JpaVendorAdapter jpaVendorAdapter = SpringContextService.getBean( "jpaVendorAdapter" );
        lcemfb.setJpaVendorAdapter( jpaVendorAdapter );

        lcemfb.afterPropertiesSet( );

        EntityManagerFactory emf = lcemfb.getNativeEntityManagerFactory( );
        _log.info( "JPA Startup Service : EntityManagerFactory created for pool : " + strPoolname );
        _log.debug( "> EMF : " + emf.toString( ) );

        JpaTransactionManager tm = new JpaTransactionManager( );
        tm.setEntityManagerFactory( emf );
        tm.setJpaDialect( jpaDialect );
        _log.debug( "> JpaDialect " + jpaDialect );
        tm.afterPropertiesSet( );
        _log.info( "JPA Startup Service : JPA TransactionManager created for pool : " + strPoolname );
        _log.debug( "> TM : " + tm.toString( ) );

        mapFactories.put( strPoolname, emf );
        listTransactionManagers.add( tm );
    }

    EntityManagerService ems = SpringContextService.getBean( "entityManagerService" );
    ems.setMapFactories( mapFactories );

    ChainedTransactionManager ctm = SpringContextService.getBean( "transactionManager" );
    ctm.setTransactionManagers( listTransactionManagers );
    _log.info( "JPA Startup Service : completed successfully" );
}
 
Example 11
Source File: EnableCmisTest.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	JpaTransactionManager txManager = new JpaTransactionManager();
	txManager.setEntityManagerFactory(entityManagerFactory().getObject());
	return txManager;
}
 
Example 12
Source File: PersistenceProductConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager productTransactionManager() {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(productEntityManager().getObject());
    return transactionManager;
}
 
Example 13
Source File: JpaConfig.java    From spring-boot-demo with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager jpaTransactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory);
    return transactionManager;
}
 
Example 14
Source File: DataConfig.java    From pizzeria with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(entityManagerFactory);
    return jpaTransactionManager;
}
 
Example 15
Source File: FhirServerConfigDstu2.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 4 votes vote down vote up
@Bean()
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager retVal = new JpaTransactionManager();
    retVal.setEntityManagerFactory(entityManagerFactory);
    return retVal;
}
 
Example 16
Source File: FhirServerConfigR5.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 4 votes vote down vote up
@Bean()
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager retVal = new JpaTransactionManager();
    retVal.setEntityManagerFactory(entityManagerFactory);
    return retVal;
}
 
Example 17
Source File: EnableJpaStoresTest.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	JpaTransactionManager txManager = new JpaTransactionManager();
	txManager.setEntityManagerFactory(entityManagerFactory().getObject());
	return txManager;
}
 
Example 18
Source File: DataConfiguration.java    From Spring with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager(){
    final JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(entityManagerFactory());
    return txManager;
}
 
Example 19
Source File: ScoreDatabaseContext.java    From score with Apache License 2.0 4 votes vote down vote up
@Bean
JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
    jpaTransactionManager.setEntityManagerFactory(entityManagerFactory);
    return jpaTransactionManager;
}
 
Example 20
Source File: PersistenceConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager jpaTransactionManager() {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}