首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >傲慢产品驾驶舱比较模式MyTypedObject ClassCastException

傲慢产品驾驶舱比较模式MyTypedObject ClassCastException
EN

Stack Overflow用户
提问于 2016-05-20 06:29:24
回答 1查看 472关注 0票数 0

狂妄自大:产品驾驶舱将ClassCastException抛到集合的比较模式。在正常模式下,它可以正常工作。

如何将MyTypedObject显式转换为集合?

我的代码片段:

代码语言:javascript
复制
Collection<CategoryModel> pCategories = ProductModel.getSupercategories();
  for (CategoryModel parentCategory : pCategories) { //ClassCastExceptionthrown
            //do something
  } }

Stacktrace

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2016-05-20 09:09:17

从特定的supercategories产品中查看HMC,这正是它所拥有的。据我所知,supercategories不必总是来自CategoryModel.类型看起来您已经用MyTypedObject.扩展了CategoryModel

比你以前在这里要做的还要多。类似于:

代码语言:javascript
复制
if (parentCategory instanceof ...)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37339439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档