Use custom condition to detect Hibernate 4.2 and 4.3

...without any deprecation warnings and with some chance that it will
still work with Hibernate 5.

Fixes gh-256