ClassCastException on ListHelper.getAddressSize(Class)
Brought to you by:
rlogiacco
ClassCastException occurs invoking ListHelper.getAddressSize(Class classType).
The ClassCastException occurs at the instruction:
Entity entity = (Entity)iter.next();
This because the getEntries method on List class returns a Set of Entry instead of a Set of object of the class specified by classType
Hello,
The problem is that the CGLIB proxy class is a direct descendent of the type of the one end of the many-to-one relationship so you will not be able to cast to the subtype while the object is being proxied.
However yuo can invoke Helper methods on a concrete subclass of Entry after finding it by its id.
The neatest solution to this is to employ the visitor pattern. This will keep code free of hibernate clutter and will also allow you to continue to use lazy loading.
It will come early.
Have to rexecute the findByKey for a collection i had just queried form the db
it's a very big limit. Helper doesn't help me....but need my help...
:-)
It's not required to use the visitor pattern,
there are very slowly simple solutions...for the problem.
Consider the previous Helper version works perfectly with the proxyied class...