All Downloads are FREE. Search and download functionalities are using the official Maven repository.

esthub-jpa.2.1.2.source-code.resthubContext.xml Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
<beans profile="resthub-jpa" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config />
    <context:component-scan base-package="org.resthub.jpa" />

    <context:property-placeholder location="classpath*:database.properties" properties-ref="databaseProperties"
        ignore-resource-not-found="true" ignore-unresolvable="true" />

    <util:properties id="databaseProperties">
        <prop key="dataSource.driverClassName">org.h2.Driver</prop>
        <prop key="dataSource.url">jdbc:h2:mem:resthub;DB_CLOSE_DELAY=-1;MVCC=TRUE</prop>
        <prop key="dataSource.username">sa</prop>
        <prop key="dataSource.password"></prop>

        <prop key="dataSource.minConnectionsPerPartition">2</prop>
        <prop key="dataSource.maxConnectionsPerPartition">4</prop>
        <prop key="dataSource.partitionCount">3</prop>

        <prop key="dataSource.idleConnectionTestPeriodInSeconds">60</prop>
        <prop key="dataSource.statementsCacheSize">100</prop>
        <prop key="dataSource.connectionTestStatement">/* ping*/ SELECT 1</prop>

        <prop key="hibernate.show_sql">false</prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
        <prop key="hibernate.format_sql">true</prop>
        <prop key="hibernate.hbm2ddl.auto">update</prop>
        <prop key="hibernate.cache.use_second_level_cache">true</prop>
        <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
        <prop key="hibernate.id.new_generator_mappings">true</prop>

        <prop key="persistenceUnit.packagesToScan"></prop>
    </util:properties>

    <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
        <property name="driverClass" value="${dataSource.driverClassName}" />
        <property name="jdbcUrl" value="${dataSource.url}" />
        <property name="username" value="${dataSource.username}"/>
        <property name="password" value="${dataSource.password}"/>

        <property name="maxConnectionsPerPartition" value="${dataSource.maxConnectionsPerPartition}"/>
        <property name="minConnectionsPerPartition" value="${dataSource.minConnectionsPerPartition}"/>
        <property name="partitionCount" value="${dataSource.partitionCount}"/>

        <property name="connectionTestStatement" value="${dataSource.connectionTestStatement}" />
        <property name="idleConnectionTestPeriodInSeconds" value="${dataSource.idleConnectionTestPeriodInSeconds}" />
        <property name="statementsCacheSize" value="${dataSource.statementsCacheSize}"/>

    </bean>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="jpaDialect">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
        </property>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="${hibernate.show_sql}" />
            </bean>
        </property>
        <property name="packagesToScan" value="${persistenceUnit.packagesToScan}" />
        <property name="jpaProperties" ref="jpaProperties" />
        <property name="dataSource" ref="dataSource" />
    </bean>

    <util:map id="resthubCoreJpaProperties">
        <entry key="hibernate.dialect" value="${hibernate.dialect}" />
        <entry key="hibernate.format_sql" value="${hibernate.format_sql}" />
        <entry key="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}" />
        <entry key="hibernate.cache.use_second_level_cache" value="${hibernate.cache.use_second_level_cache}" />
        <entry key="hibernate.cache.provider_class" value="${hibernate.cache.provider_class}" />
        <entry key="hibernate.id.new_generator_mappings" value="${hibernate.id.new_generator_mappings}" />
    </util:map>

    <bean id="jpaProperties" parent="resthubCoreJpaProperties">
        <property name="sourceMap">
            <map merge="true" />
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <tx:annotation-driven />

</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy