Added support for Hibernate 4. Fixed minor issues with JSON