{
ByteArrayOutInputStream out = new ByteArrayOutInputStream();
try {
stat.persistTo(new ObjectOutputStream(out), this);
} catch (IOException ioe) {
throw new DatabaseException("Error serializing stat " + stat, ioe);
}
byte[] data = out.toByteArray();
byte nextModCount = (byte)((stat.getModCount() + 1) % Byte.MAX_VALUE);
Key<StatRecord> key = StatRecord.getKey(playerId, stat.getCode());