I think Entity inheritence has a small issue/limitation when creating a new instance of a sub-entity.
The initNewItem method in the AbstractEditor class is defined as being called with the sub-class of the entity but at this point in the logic the actual class passed to the setItem method which calls the user hook setNewItem is called with the PARENT class so a class-cast exception is always thrown at this point. Later on in the setItem method the sub-class is determined correctly and any subsequent getItem call returns the correct sub-class.
There is a workaround for this in that the setItem method in AbstractEditor calls the postInit user hook at which time this method can call getItem to process the sub-class. However the slight issue here is that postInit can be called at other times under certain circumstances and this MAY not be desireable depending on what was intended in the user code.
I can understand that this may be a catch-22 situation (I’m not familiar enough with this code yet to determine if this is fixable) so if it is then this can only be a documentation fix to identify the restriction on using setNewItem when using inheritence entities.
I should have added that this can be recreated easily by adding a call to setNewItem in either of the sub-entity edit controllers in the sample project at GitHub - cuba-platform/sample-entity-inheritance: DEPRECATED. See https://www.cuba-platform.com/guides/data-modelling-entity-inheritance
Andrew.