我在我的代碼中一直收到ClassCastException
。最初的目標是將Set
轉換爲List
,因爲refreshDetailVOTable
方法將只獲得Set
。問題可能在於將Set
轉換爲List
。 refreshDetailVOTable
可能採取了錯誤List
這就是爲什麼我收到ClassCastException
。對此有何想法?在事件派發期間發生異常:java.lang.ClassCastException
public List deleteChildPromotionComponentDetails(ClientContext context, List detailIRsToDelete,
String emergencyAccessPermission) throws RetekBusinessException {
List exclusionList = null;
RpmEvent deleteEvent = buildPromotionComponentDetailsDeleteEvent(emergencyAccessPermission);
deleteEvent.setTransitionNotificationExceptionFlag(true);
Set detailBOsToDelete = new HashSet();
for (Iterator iDetails = detailIRsToDelete.iterator(); iDetails.hasNext();) {
IdentifiableReference detailIR = (IdentifiableReference) iDetails.next();
PromotionComponentDetail promotionComponentDetail = (PromotionComponentDetail) getService()
.readForUpdate(detailIR);
Set exclusionSet = promotionComponentDetail.getExceptionsAndExclusions();
exclusionList = new ArrayList (exclusionSet);
for(Iterator exclusion = exclusionSet.iterator(); exclusion.hasNext();){
PromotionComponentDetail exclusionDel = (PromotionComponentDetail) exclusion.next();
exclusionDel.accept(deleteEvent);
detailBOsToDelete.add(promotionComponentDetail);
}
}
return exclusionList;
}
public void deleteChildDetails(final List parentComponentDetails)
{
List list = null;
try {
list = getCmlPromotionComponentDetailAppService().deleteChildPromotionComponentDetails(
ClientContext.getInstance(), parentComponentDetails,
emergencyPermission.getName());
} catch (RetekBusinessException e) {
e.printStackTrace();
}
refreshDetailVOTable(list);
}
發佈您的錯誤堆棧跟蹤。 – user987339
您正在使用所有原始類型。改用泛型。他們將幫助您在編譯時找到這種錯誤。 –
我會嘗試一下,目前我正在研究仿製藥。你會有任何想法或示例什麼放在我的代碼編譯?謝謝@StuartMarks – awesome