Fix for supporting hibernate proxies

Sometimes the objects that are obtained from the database are hibernate proxies, which are subclasses of the actual domain classes. This change is needed to properly handle these proxies.
Merge pull request #15 from gpothier/master

Fix for supporting hibernate proxies