首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring中hibernate及事宜配置

2012-06-28 
spring中hibernate及事务配置hibernate的sessionFactory配置:!-- hibernate sessionFactory配置 --bean

spring中hibernate及事务配置

hibernate的sessionFactory配置:

<!-- hibernate sessionFactory配置 --><bean id="sessionFactory"ref="dataSource" /><property name="mappingResources"><list><value>xxx.hbm.xml</value></list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop><prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop><prop key="hibernate.connection.characterEncoding">${hibernate.connection.characterEncoding}</prop><prop key="hibernate.connection.autocommit">${hibernate.connection.autocommit}</prop><prop key="hibernate.connection.release_mode">${hibernate.connection.release_mode}</prop><prop key="hibernate.autoReconnect">${hibernate.autoReconnect}</prop><prop key="hibernate.cglib.use_reflection_optimizer">${hibernate.cglib.use_reflection_optimizer}</prop></props></property></bean>

?

定义事务管理器及事务拦截器:

<!-- 定义事务管理器  --><bean id="transactionManager"ref="sessionFactory" /></bean><!--  配置事务拦截器 --><bean id="transactionInterceptor"ref="transactionManager" /><property name="transactionAttributes"><!--  下面定义事务传播属性 --><props><prop key="save*">PROPAGATION_REQUIRED</prop><prop key="create*">PROPAGATION_REQUIRED</prop><prop key="createDomain">PROPAGATION_REQUIRES_NEW</prop><prop key="update*">PROPAGATION_REQUIRED</prop><prop key="Update*">PROPAGATION_REQUIRED</prop><prop key="modify*">PROPAGATION_REQUIRED</prop><prop key="cancel*">PROPAGATION_REQUIRED</prop><prop key="get*">PROPAGATION_REQUIRED,readOnly</prop><prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><prop key="search*">PROPAGATION_REQUIRED,readOnly</prop><prop key="Create*">PROPAGATION_REQUIRED</prop><prop key="sub*">PROPAGATION_REQUIRED</prop><prop key="finance*">PROPAGATION_REQUIRED</prop><prop key="start*">PROPAGATION_REQUIRED</prop><prop key="stop*">PROPAGATION_REQUIRED</prop><prop key="delete*">PROPAGATION_REQUIRED</prop><prop key="transfer">PROPAGATION_REQUIRED</prop><prop key="subCash*">PROPAGATION_REQUIRED</prop><prop key="send*">PROPAGATION_REQUIRED</prop><prop key="xPF*">PROPAGATION_REQUIRED</prop><prop key="pay*">PROPAGATION_REQUIRED</prop><prop key="deal*">PROPAGATION_REQUIRED</prop><prop key="transfer*">PROPAGATION_REQUIRED</prop><prop key="defaultPhone">PROPAGATION_REQUIRED</prop><prop key="open*">PROPAGATION_REQUIRED</prop><prop key="close*">PROPAGATION_REQUIRED</prop><prop key="viewUploadFile">PROPAGATION_REQUIRED</prop><prop key="page*">PROPAGATION_REQUIRED</prop></props></property></bean>

?

定义需要处理的bean即dao:

<!--定义BeanNameAutoProxyCreator,该bean是个bean后处理器,无需被引用,因此没有id属性这个bean后处理器,根据事务拦截器为目标bean自动创建事务代理 指定对满足哪些bean name的bean自动生成业务代理--><beanclass="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"><!--  下面定义BeanNameAutoProxyCreator所需的事务拦截器 --><property name="interceptorNames"><list><value>transactionInterceptor</value></list></property><!--  下面是所有需要自动创建事务代理的bean --><property name="beanNames"><list><value></value></list></property></bean>

?

热点排行