I am in the process of debugging issues of upgrading our app to Grails 5 from 3. This little bit of code was throwing an error that it could not be converted when it should have been able to.
if (item.product.instanceOf(Tissue)) {
Tissue product = (Tissue) item.product
}
after reading other post i fixed the error by Hibernate.unproxy(item.product)
and it works as expected. What changed during the upgrade to cause me to have to do this? Is there some configuration I can apply to revert the behavior back.
Looks like this was a design choice by the Grails team - https://github.com/grails/grails-data-mapping/issues/1468
We've reviewed this issue and have determined that GORM is behaving as expected in this situation.
One of the changes in GORM for Hibernate 7, is that it no longer creates custom proxy factories. It also no longer automatically unwraps Hibernate proxies. This change makes the behavior in GORM more consistent with standard Hibernate.
While the change was documented in the GORM for Hibernate Upgrade Notes we did find that our documentation needed to be updated regarding this change including guidance for situations where inheritance is involved such as the example in this issue.
The updated documentation will be published with the next release of GORM.