Hybris:产品驾驶舱在集合的比较模式下抛出 ClassCastException。在正常模式下它工作正常。
如何将 MyTypedObject 显式转换为集合?
我的代码片段:
Collection<CategoryModel> pCategories = ProductModel.getSupercategories();
for (CategoryModel parentCategory : pCategories) { //ClassCastExceptionthrown
//do something
} }
堆栈跟踪:
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | java.lang.ClassCastException: de.hybris.platform.cockpit.services.meta.impl.ExtensibleTypeService$MyTypedObject cannot be cast to de.hybris.platform.category.model.CategoryModel
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at com.org.comm.hybris.core.servicelayer.attributehandlers.DynamicTSCategoryHandler.get(DynamicTSCategoryHandler.java:42)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at com.org.comm.hybris.core.servicelayer.attributehandlers.DynamicTSCategoryHandler.get(DynamicTSCategoryHandler.java:1)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at de.hybris.platform.servicelayer.internal.model.attribute.impl.DefaultDynamicAttributesProvider.get(DefaultDynamicAttributesProvider.java:48)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at de.hybris.platform.servicelayer.model.ItemModelContextImpl.getDynamicValue(ItemModelContextImpl.java:281)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at com.org.comm.hybris.core.model.ProductModel.getMyTSSuperCategory(ProductModel.java:1669)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at java.lang.reflect.Method.invoke(Method.java:606)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:196)
INFO | jvm 1 | main | 2016/05/10 09:28:19.464 | at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:181)