-
Notifications
You must be signed in to change notification settings - Fork 175
/
spring-hibernate.xml
141 lines (114 loc) · 5.43 KB
/
spring-hibernate.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0" encoding="UTF-8"?>
<beans 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:mvc="http://www.springframework.org/schema/mvc"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="classpath:jdbc.properties"/>
<context:component-scan base-package="com.fengjing.framework.hibernate"></context:component-scan>
<tx:annotation-driven transaction-manager="hibernate4TransactionManager"/>
<aop:aspectj-autoproxy expose-proxy="true"></aop:aspectj-autoproxy>
<!-- Hibernate 4 DataSource数据源 -->
<bean id="hibernate4DataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="username" value="${username}"></property>
<property name="password" value="${password}"></property>
<property name="url" value="${hibernate4.url}"></property>
<property name="driverClassName" value="${P6Spy.driverClassName}"></property>
</bean>
<bean id="hibernate4sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="hibernate4DataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.fengjing.framework.hibernate.model.Department</value>
<value>com.fengjing.framework.hibernate.model.Employee</value>
</list>
</property>
<!--
<property name="mappingResources">
<list>
<value>com/fengjing/framework/hibernate/model/Department.hbm.xml</value>
<value>com/fengjing/framework/hibernate/model/Employee.hbm.xml</value>
</list>
</property>
-->
</bean>
<bean id="hibernate4TransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernate4sessionFactory"></property>
</bean>
<!--
<bean id="employeeDao" class="com.fengjing.framework.hibernate.dao.impl.EmployeeDao">
<property name="sessionFactory" ref="hibernate4sessionFactory"></property>
</bean>
<bean id="departmentDao" class="com.fengjing.framework.hibernate.dao.impl.DepartmentDao">
<property name="sessionFactory" ref="hibernate4sessionFactory"></property>
</bean>
<bean id="employeeServiceImpl" class="com.fengjing.framework.hibernate.service.impl.EmployeeServiceImpl">
<property name="dao" ref="employeeDao"></property>
</bean>
<bean id="departmentServiceImpl" class="com.fengjing.framework.hibernate.service.impl.DepartmentServiceImpl">
<property name="dao" ref="departmentDao"></property>
</bean>
<bean id="employeeServiceImplProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="employeeServiceImpl"></property>
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="query*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="departmentServiceImplProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="departmentServiceImpl"></property>
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="query*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="query*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config expose-proxy="true">
<aop:pointcut expression="execution(* com.fengjing.framework.hibernate.service..*.*(..))" id="pointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/>
</aop:config>
-->
</beans>