<?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>
|