这几天做了一下从Spring1.1.x + Hibernate2.x升级到Spring1.2 + hibernate3.x,具体步骤如下:
1. 修改project.xml改变dependency,spring使用1.2,hibernate使用3.0.5, 另外加入一下的依赖:hessian-2.1.12 、 pache Axis 1.2、c3p0-0.8.5.2、ehcache-1.1.jar和antlr。
2. 修改代码中net.sf.hibernate.xxxx 为org.hibernate.xxx, 另外修改org.springframework.orm.hibernate.xxx为org.springframework.orm.hibernate3.xx, 可以使用替换工具来做。
3. 接口org.hibernate.session改变了,如果使用一下的s.delete(,,,)带两个或者三个参数的method必须改变,不能在用了。
4. Spring 1.2提供的XmlBeanFactory类的构造method改变了。XmlBeanFactory(Inputstream) 改为XmlBeanFactory(InputStreamResource); 所以的代码要改变,不过很容易原来的代码套上一个new InputStreamResource().
5. 改变applicationcontext.xml或者hibernate-config.xml中LocalSessionFactoryBean等包的引入位置,即改org.springframework.orm.hibernate为org.springframework.orm.hibernate3.
在hibernate3.0中支持一个PO对应几个表的概念,类似于虚拟的view的概念。在写hbm文件是使用joined-subclass,这样就非常方便了。嘻嘻。欢迎大家讨论Spring1.2 + hibernate3.x的新特性。