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

esthub-jpa.2.0.0.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.maxActive">50</prop>
        <prop key="dataSource.maxWait">1000</prop>
        <prop key="dataSource.poolPreparedStatements">true</prop>
        <prop key="dataSource.username">sa</prop>
        <prop key="dataSource.password"></prop>
        <prop key="dataSource.validationQuery">SELECT 1</prop>
        <prop key="dataSource.testOnBorrow">true</prop>
        <prop key="dataSource.testWhileIdle">true</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.SingletonEhCacheProvider</prop>
        <prop key="hibernate.id.new_generator_mappings">true</prop>

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

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${dataSource.driverClassName}" />
        <property name="url" value="${dataSource.url}" />
        <property name="maxActive" value="${dataSource.maxActive}" />
        <property name="maxWait" value="${dataSource.maxWait}" />
        <property name="poolPreparedStatements" value="${dataSource.poolPreparedStatements}" />
        <property name="username" value="${dataSource.username}" />
        <property name="password" value="${dataSource.password}" />
        <property name="validationQuery" value="${dataSource.validationQuery}" />
        <property name="testOnBorrow" value="${dataSource.testOnBorrow}" />
        <property name="testWhileIdle" value="${dataSource.testWhileIdle}" />
    </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