我遇到了异常,我不知道如何解决。
Caused by: java.lang.ClassCastException: com.xitee.ccpt.entity.ProjectRoleSkill cannot be cast to java.lang.Long
在com.xitee.ccpt.ui.project.ProjectRoleSkillGrid $ 3.buttonClick(ProjectRoleSkillGrid.java:222)〜[classes /:na]
public void buttonClick(ClickEvent event) {
Long projectRoleSkillId = (Long) getValues().iterator().next();
ProjectRoleSkillAddWindow projectRoleAddWindow = new ProjectRoleSkillAddWindow("Add Project Role Skill",
new DialogWindowListener<ProjectRoleSkill>() {
@Override
public void dialogConfirmed(ProjectRoleSkill projectRoleSkillUpdated) {
projectRoleSkillUpdated.setProjectRole(projectRole);
projectRoleSkillUpdated.setProjectRoleSkillId(projectRoleSkillId);
projectRoleSkillService.save(projectRoleSkillUpdated);
refreshContent();
}
@Override
public void dialogClosed(boolean confirmed) { }
});
rojectRoleAddWindow.loadToEdit(projectRoleSkillService.findProjectRoleSkillByIdForEditWindow(projectRoleSkillId));
CcptUI.getCurrent().addWindow(projectRoleAddWindow);
}
答案 0 :(得分:0)
Long projectRoleSkillId = (Long) getValues().iterator().next();
这不是多头。我假设getValues()
返回类型为ProjectRoleSkill
的可迭代对象。
为避免这种情况,请不要
public Set<Object> getValues() {
return new HashSet<Object>(grid.getSelectedRows());
}
您应该将方法签名重写为
public Set<ProjectRoleSkill> getValues() {
return new HashSet<>(grid.getSelectedRows());
}
这样,IDE将不允许您转换为Long。然后,您还可以看到getId()
类中的ProjectRoleSkill
方法。