another potential solution to this problem is to use polymorfic methods on the object.
i believe that is the only solution that will really work.
for WireContext and Initializable, you could e.g. introduce a method isInitializable on the Descriptor or AbstractDescriptor
The method isInitializable can be used to check if the object is an instance of Initializable, but the cast still fails.
In the WireContext, there 's a list of pendingInitialization. A pending init has a Initializable.
To remove the cast, we need to change pendingInitialization to use only AbstractDescriptor, and to add an empty "initialize" method in AbstractDescriptor.
With the change, the tests pass. Is this a good way to resolve this issue ?
Yes - you need ProxyVisitorPattern: http://community.jboss.org/wiki/ProxyVisitorPattern because lazy polymorphic are proxies and not your types.
Other solution: split you entity class to interface and implementation so then in mapping subclasses you can specify the interface name in proxy attribute. See