/
resthubContext.xml
79 lines (67 loc) · 3.94 KB
/
resthubContext.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<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">
<import resource="hikariCPContext.xml"/>
<import resource="boneCPContext.xml"/>
<context:annotation-config />
<context:component-scan base-package="org.resthub.jpa" />
<context:property-placeholder location="classpath*:persistence.properties" properties-ref="databaseProperties"
ignore-resource-not-found="true" ignore-unresolvable="true" />
<util:properties id="databaseProperties">
<!-- JPA & Hibernate Resthub specific defaults -->
<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="dataSourceProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:datasource.properties"/>
<property name="ignoreResourceNotFound" value="true" />
<property name="properties" ref="defaultDataSourceProperties"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="${persistenceUnit.packagesToScan}" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${hibernate.show_sql}" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaProperties" ref="jpaProperties" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider"/>
</property>
</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>