今天将spring与hibernate进行整合,非常的不顺利,终于发现了原因。所以将发现进行记录,希望对以后有所帮助。
其实使用myEclipse对spring与hibernate进行整合并没有先后顺序,都是可以的。
方式一:先添加hibernate再添加spring
这种方式会将hibernate的主配置信息进行单独配置,也就是会有hibernate.cfg.xml和applicationContext.xml两个配置文件。
这种方式的sessionFactory配置:
方式二:先添加spring再添加hibernate
这种方式会将hibernate的主配置信息也放入applicationContext.xml文件中,也就是都由spring进行统一管理,只有applicationContext.xml一个文件。
这种方式的sessionFactory配置:
【注意】hibernate4,自认为非常好,没有对springHibernateDaoSupport进行支持