Where where = new Where(StatRecord.PLAYER_ID, playerId,
StatRecord.STAT_CODE, modifier.getType().code());
for (int ii = 0; ii < MAX_UPDATE_TRIES; ii++) {
StatRecord record = load(StatRecord.class, where); // TODO: force cache skip on ii > 0
Stat stat = (record == null) ? modifier.getType().newStat() :
decodeStat(record.statCode, record.statData, record.modCount);
@SuppressWarnings("unchecked") T tstat = (T)stat;
modifier.modify(tstat);
if (!tstat.isModified()) {
return null;