xml配置spring集成hibernate
发布时间:2020-12-16 06:19:52 所属栏目:百科 来源:网络整理
导读:?xmlversion="1.0"encoding="UTF-8"?beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework
<?xmlversion="1.0"encoding="UTF-8"?> <beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!--初始化证书信息bean存储pfx信息单例--> <beanid="initpfx"class="com.yjm.initcert.InitX509CertInfo" scope="singleton"></bean> <!--取得返回sessionFactory对象--> <beanid="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <propertyname="configLocation"value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 取得hibernate的sessionfactory去封装spring自己的事务管理器事务管理器比hibernate自带的强大很多 --> <beanid="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <propertyname="sessionFactory"ref="sessionFactory"/> </bean> <!--数据处理DAO类sessionfactory工厂类DAOsessionFactory单例处理--> <beanid="commondao"class="com.yjm.dao.CommonDAO"scope="singleton"> <propertyname="sessionFactory"ref="sessionFactory"></property> </bean> <!--逻辑处理service类Food--> <beanid="foodservice"class="com.yjm.service.FoodService"> <propertyname="commonDAO"ref="commondao"></property> </bean> <!--逻辑处理service类User--> <beanid="userservice"class="com.yjm.service.UserService"> <propertyname="commonDAO"ref="commondao"></property> </bean> <!--逻辑处理service类UserInfo--> <beanid="userinfo"class="com.yjm.service.UserInfoService"> <propertyname="commonDAO"ref="commondao"></property> </bean> <!--l--> <!--用代理类对TransactionManager进行组合切面事务管理--> <tx:adviceid="advice"transaction-manager="transactionManager"> <tx:attributes> <tx:methodname="find*"propagation="REQUIRED"read-only="true"/> <tx:methodname="select*"propagation="REQUIRED"read-only="true"/> <tx:methodname="load*"propagation="REQUIRED"read-only="true"/> <tx:methodname="get*"propagation="REQUIRED"/> <tx:methodname="save*"propagation="REQUIRED"/> </tx:attributes> </tx:advice> <!--定义切面--> <aop:config> <aop:pointcutexpression="execution(*com.yjm.service.*.*(..))" id="point"/> <aop:advisoradvice-ref="advice"pointcut-ref="point"/> </aop:config> </beans> sessionFactory 注入 类 默认返回的是Hibernate sessionFactory 对象 用hibernate sessionFactory 封装 spring 自己的transactionManager,spring自己的事务管理器比hibernate的 事务管理器 强大。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c – 操作符<< for QString
- 动态构建双轴的FLEX报表
- linq – 传递lambda表达式代替IComparer或IEqualityCompare
- 如何创建用于OpenCV的Haar Cascade(xml)?
- C中的system()时出现分段错误
- ruby – ERROR URI :: InvalidURIError:由于浏览器,错误的
- ruby-on-rails – 使用Globalize&Friendly_id将同一页面
- postgresql – 如何在postgresSQL中的jsonb值的array_agg中
- A survey of Flash Translation Layer——笔记注释
- 有没有办法设置$的值?在Ruby中的模拟?