Long projectRoleSkillId = (Long) getValues().iterator().next();
This is not a Long. I assume getValues()
returns an iterable of type ProjectRoleSkill
.
To avoid this, instead of having
public Set<Object> getValues() {
return new HashSet<Object>(grid.getSelectedRows());
}
you should rewrite the method signature to
public Set<ProjectRoleSkill> getValues() {
return new HashSet<>(grid.getSelectedRows());
}
This way, the IDE won’t let you cast to Long. You’ll also then be able to see the getId()
method I assume is on the ProjectRoleSkill
class.
7
solved Exception: cannot be cast to java.lang.Long [closed]