spring3.1+hibernate4.1关于事务的配置

spring3.1+hibernate4.1关于事务的配置 --》搞了很久 不过hibernate的更新过快!!!!spring是不是跟不上啊

标签: Hibernate Spring

[1].[代码] spring3.1+hibernate4.1关于事务的配置 跳至 [1]

?
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
---注意hibernate4的版本头信息与hibernate3的不同 可能会报错  具体的可以到hibernate核心包下copy
 
<?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:p= "http://www.springframework.org/schema/p"
     xmlns:aop= "http://www.springframework.org/schema/aop"
     xmlns:tx= "http://www.springframework.org/schema/tx"
     xsi:schemaLocation="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
     ">
    <bean id= "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" >
          <property name= "driverClass" value= "com.microsoft.sqlserver.jdbc.SQLServerDriver" >
          </property>
          <property name= "jdbcUrl" value= "jdbc:sqlserver://localhost:1433;databaseName=FundDb" >
          </property>
          <property name= "user" value= "sa" ></property>
          <property name= "password" value= "123456" ></property>
     </bean>
     
     <bean id= "sessionFactory" class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
           <property name= "dataSource" ref= "dataSource" ></property> 
          <property name= "hibernateProperties"
          <props> 
                 <prop key= "hibernate.dialect"
                     org.hibernate.dialect.SQLServerDialect
                </prop> 
                <prop key= "hibernate.show_sql" > true </prop>
                
                <prop key= "hibernate.cache.use_second_level_cache" > true </prop>
                <prop key= "hibernate.cache.use_query_cache" > true </prop>
                <prop key= "hibernate.cache.region.factory_class" >org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
                 </props> 
        </property> 
         <property name= "mappingResources"
            <list> 
                  <value>com/entity/Admin.hbm.xml</value> 
            </list> 
          </property> 
     </bean> 
     <bean id= "tran" class = "org.springframework.orm.hibernate4.HibernateTransactionManager" >
         <property name= "sessionFactory"  ref= "sessionFactory" ></property>
     </bean>
      
      <tx:advice id= "aa" transaction-manager= "tran" >
             <tx:attributes>
                    <tx:method name= "add*" propagation= "REQUIRED"  isolation= "READ_COMMITTED"   />
                    <tx:method name= "*" read-only= "true" propagation= "REQUIRED" />
             </tx:attributes>
      </tx:advice>
      
      <aop:config proxy-target- class = "true" >
            <aop:pointcut expression= "execution(* com.dao.*.addoneadmin(..))" id= "my" />
            <aop:advisor advice-ref= "aa"  pointcut-ref= "my" />
      </aop:config>
        
     <bean id= "admindao" class = "com.dao.AdminDao" p:sf-ref= "sessionFactory" ></bean>
      
     </beans>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值