Upgrading to Spring 1.2 RC1 and Hibernate 3.0
I spent an hour or so on Friday upgrading Equinox and AppFuse to use Spring 1.2 RC1 and Hibernate 3.0. The upgrade for AppFuse was relatively painless, but the upgrade for Equinox failed. Equinox uses HSQLDB version 1.7.1. The main reason I use the 1.7.1 version is to avoid the infamous "lock exception" that the new HSQL version throws in standalone mode. With version 1.7.1, it seems you could have more than one connection open to the file-based database w/ no problem. I really like this feature in 1.7.1 b/c it means you can run the app in Tomcat and browse the database at the same time.
So what's the problem? Why can't I just use Hibernate 3.0 with HSQL 1.7.1? The problem is I like using the following setting as part of my "sessionFactory" bean:
<prop key="hibernate.hbm2ddl.auto">update</prop>
This setting will update the schema when you change mapping files, but otherwise leave the data intact. Furthermore, it'll actually create the tables if they don't exist. Not so with Hibernate 3. With Hibernate 3, using "update" doesn't create the tables. Of course, upgrading to a newer version of HSQL fixes the problem, but then I get the lock problem. My eventual solution will probably be to hack Hibernate or HSQL, but for now I just won't upgrade Equinox. Another solution might be to look at some other embedded databases. Of course, I could also require users to install a database to run Equinox - but I like having the "no setup required" feature.
Regardless of the problems I experienced with HSQL and Hibernate 3, upgrading AppFuse was pretty painless. Here's the set of instructions I sent to the mailing list:
- Download Hibernate 3.0 and Spring 1.2 RC1.
- Create a lib/spring-1.2-rc1 and put the following files in it (NOTE: spring.jar now contains aopalliance.jar):
acegi-security-0.8.1.jar commons-codec.jar ehcache-1.1.jar license.txt spring-mock.jar spring.jar
- Create a lib/hibernate-3.0 and put the following files in it:
hibernate3.jar lgpl.jar lib/antlr-2.7.5H3.jar antlr.license.txt asm.jar c3p0-0.8.5.jar c3p0.license.txt cglib-2.1.jar dom4j-1.5.2.jar jta.jar jta.licence.txt oscache-2.1.jar swarmcache-1.0rc2.jar
- Change the versions for Hibernate and Spring in lib/lib.properties. Also, change the hibernate.jar property to reference hibernate3.jar instead of hibernate2.jar.
- In build.xml, change the "package-web" target to include all the
Hibernate JARs instead of just specific ones:
<lib dir="${hibernate.dir}/lib" includes="*.jar" excludes="jta.jar"/>
- Change web/common/taglibs.jsp to use uri="/oscache" for the oscache taglib.
- Search for "net.sf.hibernate" and replace it with "org.hibernate".
- Search for "orm.hibernate" and replace it with "orm.hibernate3" (for Spring).
The major difference for Hibernate is you no longer need odmg-3.0.jar, but you do need asm.jar and antlr-2.7.5H3.jar.
Let me know if you find any issues with these instructions. You could also just download AppFuse from CVS.
NOTE: The CVS version of AppFuse has an XDoclet version that only supports generating Hibernate 2.x mapping files. I believe there is support for Hibernate 3 in XDoclet's CVS - but I haven't had a chance to upgrade yet.
Update: Here's more on the HSQL bug that's not really a bug (according to a comment on the post). Regardless of whether it's a bug or not, it'd be nice to have the 1.7.1 behavior as an option - it's a great feature for get-started-quick apps like Equinox.
Posted by Chris Nelson on April 04, 2005 at 02:01 AM MDT #
Posted by Vui Lo on April 04, 2005 at 05:22 AM MDT #
Posted by Jason Carreira on April 04, 2005 at 05:34 PM MDT #
Posted by sib on April 04, 2005 at 06:32 PM MDT #
Posted by Richard Sullivan on April 05, 2005 at 03:34 PM MDT #
Posted by Matt Raible on April 06, 2005 at 05:26 AM MDT #
Posted by Anatol Pomozov on April 07, 2005 at 03:51 PM MDT #
The main reason I won't be moving to XDoclet2 anytime soon is because all the templates in AppFuse's AppGen are written using XDoclet 1.x's XDT templates. Ugly, but it works great!
Posted by Matt Raible on April 07, 2005 at 03:55 PM MDT #
Posted by javapda on June 14, 2005 at 05:06 PM MDT #