You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
Steps to Reproduce
Create 3 Domain classes, where one is a subclass of another and the third (container) contains a reference to the superclass
Create an instance of the containing class, assign an instance of the subclass and save it
Try to access a property of the referenced superclass in the loaded container instance
Expected Behaviour
The value of the property should be returned. In OO the subclass can be used everywhere the superclass is expected which is not the case here.
Actual Behaviour
A ClassCastException is thrown:
Caused by ClassCastException: four.zero.gorm.SuperChild$HibernateProxy$dMa7Faoo cannot be cast to four.zero.gorm.SubChild
->> 10 | doCall in ContainerController.groovy
| 211 | invoke in org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker
| 188 | invoke . . . . . in org.grails.core.DefaultGrailsControllerClass
| 90 | handle in org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter
| 1040 | doDispatch . . . in org.springframework.web.servlet.DispatcherServlet
| 943 | doService in ''
| 1006 | processRequest . in org.springframework.web.servlet.FrameworkServlet
| 898 | doGet in ''
| 883 | service . . . . in ''
| 77 | doFilterInternal in org.grails.web.servlet.mvc.GrailsWebRequestFilter
| 67 | doFilterInternal in org.grails.web.filters.HiddenHttpMethodFilter
| 1149 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 624 | run . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run in java.lang.Thread
Start the app and just invoke /container/saveSub to see the exception. Using /container/saveSuper you can see that it works as expected if the referenced entity is of the super class type.
The text was updated successfully, but these errors were encountered:
Task List
Steps to Reproduce
Expected Behaviour
The value of the property should be returned. In OO the subclass can be used everywhere the superclass is expected which is not the case here.
Actual Behaviour
A ClassCastException is thrown:
Caused by ClassCastException: four.zero.gorm.SuperChild$HibernateProxy$dMa7Faoo cannot be cast to four.zero.gorm.SubChild
->> 10 | doCall in ContainerController.groovy
| 211 | invoke in org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker
| 188 | invoke . . . . . in org.grails.core.DefaultGrailsControllerClass
| 90 | handle in org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter
| 1040 | doDispatch . . . in org.springframework.web.servlet.DispatcherServlet
| 943 | doService in ''
| 1006 | processRequest . in org.springframework.web.servlet.FrameworkServlet
| 898 | doGet in ''
| 883 | service . . . . in ''
| 77 | doFilterInternal in org.grails.web.servlet.mvc.GrailsWebRequestFilter
| 67 | doFilterInternal in org.grails.web.filters.HiddenHttpMethodFilter
| 1149 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 624 | run . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 748 | run in java.lang.Thread
Environment Information
Example Application
https://github.com/miq/grails-class-cast
Start the app and just invoke /container/saveSub to see the exception. Using /container/saveSuper you can see that it works as expected if the referenced entity is of the super class type.
The text was updated successfully, but these errors were encountered: