Spring与Hibernate(基于Anotation)整合时applicationContext的具体配置

Spring与Hibernate(基于Anotation)整合时applicationContext的具体配置
因为Hibernate采用Anotation的方式配置,故而在applicationContext中sesionFactory应该基于 AnnotationSessionFactoryBean,具体代码如下:
 1  < bean id = " sessionFactory "   class = " org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean " >
 2       < property name = " dataSource "  ref = " dataSource " ></ property >
 3       < property name = " hibernateProperties " >
 4           < props >
 5               < prop key = " hibernate.dialect " > org.hibernate.dialect.MySQLDialect </ prop >
 6               < prop key = " hibernate.show_sql " > true </ prop >
 7           </ props >
 8       </ property >
 9       < property name = " annotatedClasses " >
10               < list >
11                   < value > com.donghang.bean.User </ value >
12               </ list >
13       </ property >
14  </ bean >
其中User即为采用Anotation映射的实体类。



你可能感兴趣的:(Spring与Hibernate(基于Anotation)整合时applicationContext的具体配置)