Hibernate highlighted bugfixes

In the (aborted) attempt to port to hibernate, the different validations hibernate implements highlighted some bugs that were not found by openjpa.