PollsQuestionUtil.update(question);
PollsVotePK votePK = new PollsVotePK(questionId, userId);
PollsVote vote = null;
try {
vote = PollsVoteUtil.findByPrimaryKey(votePK);
throw new DuplicateVoteException();
}
catch (NoSuchVoteException nsve) {
vote = PollsVoteUtil.create(votePK);
PollsChoicePK choicePK =
new PollsChoicePK(questionId, choiceId);
PollsChoice choice = PollsChoiceUtil.findByPrimaryKey(choicePK);
vote.setChoiceId(choice.getChoiceId());
vote.setVoteDate(now);
PollsVoteUtil.update(vote);
}
}