读书人

在Spring中配备SessionFactory的二种方

发布时间: 2012-09-06 10:37:01 作者: rapoo

在Spring中配置SessionFactory的二种方式

在Spring中配置SessionFactory的二种方式

第一种方式:

把Hibernate的配置文件hibernate.cfg.xml配置到applicationContext.xml中

<bean id="sessionFactory"  value="file:src/hibernate.cfg.xml">   </property></bean>

第二种方式:

利用dataSource来配置SessionFactory

<bean id="sessionFactory"value="dataSource"></property><property name="mappingResources"><list><value>com/pojo/Guestbook.hbm.xml</value>                        <value>com/pojo/User.hbm.xml</value>                                    ......</list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop></props></property></bean>

读书人网 >软件架构设计

热点推荐