派生自 projectDept/qhighschool

yn147
2023-11-23 42c48ce1d64e941d28c7bfe4093f9659e77bd523
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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
 
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/jee
        http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
 
    <!-- <aop:aspectj-autoproxy proxy-target-class="true" /> -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="druidDataSource" />
 
        <!-- 配置Entity扫描包名 -->
        <property name="packagesToScan">
            <list>
                <value>com.qxueyou.scc</value>
            </list>
        </property>
 
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                     com.qxueyou.scc.base.handler.QxueyouMysqlDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="connection.characterEncoding">GBK</prop>
                <!-- <prop key="hibernate.physical_naming_strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop> -->  
                <prop key="hibernate.physical_naming_strategy">org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy</prop> 
                
                 <prop key="hibernate.cache.use_second_level_cache">false</prop>
                <!-- 
                <prop key="hibernate.cache.region.factory_class">
                    com.googlecode.hibernate.memcached.MemcachedRegionFactory
                </prop>
                <prop key="hibernate.memcached.keyStrategy">HashCodeKeyStrategy</prop>
                <prop key="hibernate.memcached.servers">192.168.10.230:11211</prop>
                缓存失效时间,单位秒
                <prop key="hibernate.memcached.cacheTimeSeconds">600</prop>
                Hibernate将收集有助于性能调节的统计数据
                <prop key="hibernate.generate_statistics">true</prop>
                
                设置二级缓存的前缀名称  
                 <prop key="hibernate.cache.region_prefix">qxueyou_query_cache</prop>
                是否缓存查询结果  
                <prop key="hibernate.cache.use_query_cache">true</prop>
                否使用结构化的方式缓存对象   
                 <prop key="hibernate.cache.use_structured_entries">true</prop>  
                 -->
            </props> 
        </property> 
    </bean>
 
    <!-- the transactional advice (what happens; see the <aop:advisor/> bean 
        below) -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="delete*" propagation="REQUIRED" />
            <tx:method name="do*" propagation="REQUIRED" />
            <tx:method name="execute*" propagation="REQUIRED" />
            <tx:method name="logSave*" propagation="REQUIRES_NEW" />
            <tx:method name="*" read-only="true" />
        </tx:attributes>
    </tx:advice>
 
    <aop:config>
        <aop:pointcut id="allManagerMethod"
            expression="execution(* com.qxueyou.scc..*Service.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
    </aop:config>
 
    <bean id="txManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    
</beans>