hibernate只用注解时,spring的配置文件的配置如下
com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/oa root 5519585 30
com.zhongkai.oa.model org.hibernate.dialect.MySQLDialect update true true org.hibernate.cache.EhCacheProvider
hibernate即用注解也用配置文件的情况:首先hibernate配置文件内容如下:
然后spring配置文件内容:
com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/oa root 5519585 30
com.zhongkai.oa.model classpath:hibernate.cfg.xml org.hibernate.dialect.MySQLDialect update true true org.hibernate.cache.EhCacheProvider
在sessionFactoryBean中增加了元素
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value> </property>