Tuesday, March 20, 2012

Grails instanceOf vs Java instanceof

In Grails, there is a method attached to each domain object called "instanceOf" click here

It is important to note that this method is different from the Java instanceof operator.

The Grails version of instanceOf, is used to test instances that have been wrapped as hibernate proxies for their true object type.
These proxies only subclass the generic type used to identify it's type. The problem of dealing with Hibernate proxies has been explained in more detail in this other blog entry of mine here.