Hi
Suggest to have a previousWinner stored in your assembler,
when there is an update, delete or create. Run your logic to
determine who is the winner.
public void pushNewWinner()
{
Member previousWinner = winner;
winner = findWinner();
if (winner.id == previousWinner.id)
return;
DataServiceTransaction dst =
DataServiceTransaction.begin(useJTA);
String[] changedProperties = {"isWinner"};
Member original = winner.clone();
original.isWinner = false;
winner.isWinner = true;
dst.updateItem("Members", winner , original
,changedProperties);
orignal = previousWinner.clone();
previousWinner.isWinner = false;
previousWinner.isWinner = true;
dst.updateItem("Members", prevopisWinner , original
,changedProperties);
dst.commit();
}
You might need to try catch updates and dst.commit()
infinally, catch exception to dst.setRollbackOnly();
William Chan