BatooOrg/BatooJPA — pull request #183 by ylemoigne (2013-03-23 21:00:55+00:00)
Title: Bug on abstract entity

This one is a little tricky because the case is wicked.

To work around the "hibernate proxy breaks instanceof" problems while keeping lazy loading, we used the code which is in that testcase.

It's a trick based on the following fact :
- If a method exist in lower classes in the hierarchy, hibernate must unproxy the instance to allow method execution.
- If a method return the same instance of the method on which we execute the method, hibernate proxy return the proxy rather than the 'this' of the method.

So, by calling unwrapper() on the instance, we bind hibernate to unproxy the instance, by returning an instance of another object, it won't replace the return result by another thing.

Then we can call unwrap() to get the unwrapped instance of the object.