There are two big things that I love about the Spring Framework:
- It has excellent Hibernate support through the use of its HibernateTemplate class
- It makes writing JUnit tests much simpler, yielding better code
Recently, however, I came across a great article explaining how to unit test Hibernate mapping configurations. The article goes into how to create your session factory, and wire up your DAO with a new HibernateTemplate. It even gives tips on how to setup an in-memory HSQLDB database for testing. This reduces the overhead needed to perform your tests, as you don't need a full-fledged SQL database to run your tests against.
If you write any Hibernate-based code and are looking for a means of testing your Hibernate configuration, this is article is a great referrence.