Json support hibernate3

Json support for Hibernate 3. The commits of the PR #40 cherry-picked and modified to be hibernate 3 compatible.

Ready to merge! :-)