I wrote a blog details how to set up distributed EhCache as a second level cache for Hibernate
http://unserializableone.blogspot.com/2007/09/distributed-ehcache-as-second-level.html
The source code of the whole project is in the attachment. You will need to download Terracotta 2.4.3 (as of 09/2007) to try it out.
You can also check it out of SVN repo http://svn.terracotta.org/svn/forge/projects/labs/hibernate-ehcache