/
common-dao-sql-test-context.xml
87 lines (72 loc) · 4.16 KB
/
common-dao-sql-test-context.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
80
81
82
83
84
85
86
87
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014 CyberVision, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- In order to implement support of custom SQL platform, one should declare following mandatory beans -->
<!-- End of mandatory beans declaration -->
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<beans profile="postgres">
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="org.kaaproject.kaa.server.common.dao.model.sql"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">#{dao[hibernate_hbm2ddl_auto]}</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL82Dialect</prop>
<prop key="hibernate.format_sql">#{dao[hibernate_format_sql]}</prop>
<prop key="hibernate.show_sql">#{dao[hibernate_show_sql]}</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://127.0.0.1:5432/kaa"/>
<property name="username" value="postgres"/>
<property name="password" value="admin"/>
</bean>
</beans>
<beans profile="h2">
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="org.kaaproject.kaa.server.common.dao.model.sql"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">#{dao[hibernate_hbm2ddl_auto]}</prop>
<prop key="hibernate.dialect">#{dao[hibernate_dialect]}</prop>
<prop key="hibernate.format_sql">#{dao[hibernate_format_sql]}</prop>
<prop key="hibernate.show_sql">#{dao[hibernate_show_sql]}</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="#{dao[jdbc_driver_className]}"/>
<property name="url" value="jdbc:#{dao[jdbc_url_db_name]}:mem:kaa;DATABASE_TO_UPPER=true;MODE=PostgreSQL"/>
<property name="username" value="#{dao[jdbc_username]}"/>
<property name="password" value="#{dao[jdbc_password]}"/>
</bean>
<!-- provides a H2 console to look into the db if necessary -->
<!-- Connection instructions : go to http://localhost:11111 -->
<bean id="org.h2.tools.Server-WebServer" class="org.h2.tools.Server"
factory-method="createWebServer" depends-on="dataSource"
init-method="start" lazy-init="false" destroy-method="stop">
<constructor-arg value="-web,-webPort,11111"/>
</bean>
</beans>
</beans>