Updated to new Depot world order.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@797 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2009-01-08 02:10:42 +00:00
parent b748974845
commit a8f4e9fc9b
8 changed files with 72 additions and 151 deletions
@@ -13,12 +13,8 @@ import com.samskivert.depot.expression.ColumnExp;
public class MaxStatCodeRecord extends PersistentRecord {
// AUTO-GENERATED: FIELDS START
/** The column identifier for the {@link #maxCode} field. */
public static final String MAX_CODE = "maxCode";
/** The qualified column identifier for the {@link #maxCode} field. */
public static final ColumnExp MAX_CODE_C =
new ColumnExp(MaxStatCodeRecord.class, MAX_CODE);
public static final Class<MaxStatCodeRecord> _R = MaxStatCodeRecord.class;
public static final ColumnExp MAX_CODE = colexp(_R, "maxCode");
// AUTO-GENERATED: FIELDS END
@Column
@@ -32,33 +32,11 @@ import com.samskivert.depot.expression.ColumnExp;
public class StatRecord extends PersistentRecord
{
// AUTO-GENERATED: FIELDS START
/** The column identifier for the {@link #playerId} field. */
public static final String PLAYER_ID = "playerId";
/** The qualified column identifier for the {@link #playerId} field. */
public static final ColumnExp PLAYER_ID_C =
new ColumnExp(StatRecord.class, PLAYER_ID);
/** The column identifier for the {@link #statCode} field. */
public static final String STAT_CODE = "statCode";
/** The qualified column identifier for the {@link #statCode} field. */
public static final ColumnExp STAT_CODE_C =
new ColumnExp(StatRecord.class, STAT_CODE);
/** The column identifier for the {@link #statData} field. */
public static final String STAT_DATA = "statData";
/** The qualified column identifier for the {@link #statData} field. */
public static final ColumnExp STAT_DATA_C =
new ColumnExp(StatRecord.class, STAT_DATA);
/** The column identifier for the {@link #modCount} field. */
public static final String MOD_COUNT = "modCount";
/** The qualified column identifier for the {@link #modCount} field. */
public static final ColumnExp MOD_COUNT_C =
new ColumnExp(StatRecord.class, MOD_COUNT);
public static final Class<StatRecord> _R = StatRecord.class;
public static final ColumnExp PLAYER_ID = colexp(_R, "playerId");
public static final ColumnExp STAT_CODE = colexp(_R, "statCode");
public static final ColumnExp STAT_DATA = colexp(_R, "statData");
public static final ColumnExp MOD_COUNT = colexp(_R, "modCount");
// AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 4;
@@ -124,7 +102,7 @@ public class StatRecord extends PersistentRecord
{
return new Key<StatRecord>(
StatRecord.class,
new String[] { PLAYER_ID, STAT_CODE },
new ColumnExp[] { PLAYER_ID, STAT_CODE },
new Comparable[] { playerId, statCode });
}
// AUTO-GENERATED: METHODS END
@@ -62,8 +62,8 @@ public class StatRepository extends DepotRepository
*/
public <T extends Stat> T updateStat (int playerId, StatModifier<T> modifier)
{
Where where = new Where(StatRecord.PLAYER_ID_C, playerId,
StatRecord.STAT_CODE_C, modifier.getType().code());
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
@@ -91,7 +91,7 @@ public class StatRepository extends DepotRepository
public ArrayList<Stat> loadStats (int playerId)
{
ArrayList<Stat> stats = new ArrayList<Stat>();
Where where = new Where(StatRecord.PLAYER_ID_C, playerId);
Where where = new Where(StatRecord.PLAYER_ID, playerId);
for (StatRecord record : findAll(StatRecord.class, where)) {
Stat stat = decodeStat(record.statCode, record.statData, record.modCount);
if (stat != null) {
@@ -106,7 +106,7 @@ public class StatRepository extends DepotRepository
*/
public void deleteStats (final int playerId)
{
deleteAll(StatRecord.class, new Where(StatRecord.PLAYER_ID_C, playerId));
deleteAll(StatRecord.class, new Where(StatRecord.PLAYER_ID, playerId));
}
/**
@@ -243,9 +243,9 @@ public class StatRepository extends DepotRepository
// update the row in the database only if it has the expected modCount
int numRows = updatePartial(
StatRecord.class,
new Where(StatRecord.PLAYER_ID_C, playerId,
StatRecord.STAT_CODE_C, stat.getCode(),
StatRecord.MOD_COUNT_C, stat.getModCount()),
new Where(StatRecord.PLAYER_ID, playerId,
StatRecord.STAT_CODE, stat.getCode(),
StatRecord.MOD_COUNT, stat.getModCount()),
key,
StatRecord.STAT_DATA, data, StatRecord.MOD_COUNT, nextModCount);
@@ -284,8 +284,8 @@ public class StatRepository extends DepotRepository
MaxStatCodeRecord.class,
new FromOverride(StringCodeRecord.class),
new FieldDefinition(MaxStatCodeRecord.MAX_CODE,
new FunctionExp("MAX", StringCodeRecord.CODE_C)),
new Where(StringCodeRecord.STAT_CODE_C, type.code()));
new FunctionExp("MAX", StringCodeRecord.CODE)),
new Where(StringCodeRecord.STAT_CODE, type.code()));
int code = maxRecord != null ? maxRecord.maxCode + 1 : 1;
@@ -327,7 +327,7 @@ public class StatRepository extends DepotRepository
{
QueryClause[] clauses;
if (type != null) {
clauses = new QueryClause[] { new Where(StringCodeRecord.STAT_CODE_C, type.code()) };
clauses = new QueryClause[] { new Where(StringCodeRecord.STAT_CODE, type.code()) };
} else {
clauses = new QueryClause[0];
}
@@ -26,51 +26,46 @@ import com.samskivert.depot.PersistentRecord;
import com.samskivert.depot.annotation.Column;
import com.samskivert.depot.annotation.Entity;
import com.samskivert.depot.annotation.Id;
import com.samskivert.depot.annotation.UniqueConstraint;
import com.samskivert.depot.annotation.Index;
import com.samskivert.depot.expression.ColumnExp;
@Entity(name="STRING_CODES", uniqueConstraints={
@UniqueConstraint(fieldNames={ StringCodeRecord.STAT_CODE, StringCodeRecord.VALUE }),
@UniqueConstraint(fieldNames={ StringCodeRecord.STAT_CODE, StringCodeRecord.CODE })})
@Entity(name="STRING_CODES", indices={
@Index(name="statCodeValue", unique=true),
@Index(name="statCodeCode", unique=true)
})
public class StringCodeRecord extends PersistentRecord
{
// AUTO-GENERATED: FIELDS START
/** The column identifier for the {@link #statCode} field. */
public static final String STAT_CODE = "statCode";
/** The qualified column identifier for the {@link #statCode} field. */
public static final ColumnExp STAT_CODE_C =
new ColumnExp(StringCodeRecord.class, STAT_CODE);
/** The column identifier for the {@link #value} field. */
public static final String VALUE = "value";
/** The qualified column identifier for the {@link #value} field. */
public static final ColumnExp VALUE_C =
new ColumnExp(StringCodeRecord.class, VALUE);
/** The column identifier for the {@link #code} field. */
public static final String CODE = "code";
/** The qualified column identifier for the {@link #code} field. */
public static final ColumnExp CODE_C =
new ColumnExp(StringCodeRecord.class, CODE);
public static final Class<StringCodeRecord> _R = StringCodeRecord.class;
public static final ColumnExp STAT_CODE = colexp(_R, "statCode");
public static final ColumnExp VALUE = colexp(_R, "value");
public static final ColumnExp CODE = colexp(_R, "code");
// AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 2;
/** Defines the statCodeValue unique index. */
public static ColumnExp[] statCodeValue ()
{
return new ColumnExp[] { STAT_CODE, VALUE };
}
/** Defines the statCodeCode unique index. */
public static ColumnExp[] statCodeCode ()
{
return new ColumnExp[] { STAT_CODE, CODE };
}
/** The code of the stat. */
@Id
@Column(name="STAT_CODE")
@Id @Column(name="STAT_CODE")
public int statCode;
@Id
@Column(name="VALUE")
@Id @Column(name="VALUE")
public String value;
@Column(name="CODE")
public int code;
/**
* An empty constructor for unmarshalling.
*/
@@ -99,7 +94,7 @@ public class StringCodeRecord extends PersistentRecord
{
return new Key<StringCodeRecord>(
StringCodeRecord.class,
new String[] { STAT_CODE, VALUE },
new ColumnExp[] { STAT_CODE, VALUE },
new Comparable[] { statCode, value });
}
// AUTO-GENERATED: METHODS END