hibernate +spring sessionfactory 配置

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
<property name="dataSource" ref="dataSource"></property> 
<!--<property name="configLocation" value="hibernate.cfg.xml"></property>-->         (3)
<property name="hibernateProperties"> 
<props> 
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 
<prop key="hibernate.show_sql">true</prop> 
<prop key="hibernate.format_sql">true</prop> 
<prop key="hibernate.hbm2ddl.auto">update</prop> 
<prop key="hibernate.cache.use_second_level_cache">true</prop> 
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> 
</props> 
</property> 
<property name="packagesToScan" value="xxx.xxx" /> 
</bean> 

上面的就是hibernate的sessionfactory的配置,其中最下面的</property> 
<property name="packagesToScan" value="xxx.xxx" /> 
就是告訴hibernate在xxx.xxx這個包下去搜索註釋生成數據庫表spring

若是用(3)的配置就須要hibernate.cfg.xmlsql

相關文章
相關標籤/搜索