As tidy as it was to tuck this record away inside StatRepository, we'd really like the benefit of the 'genrecord' transformation. Also the inner class couldn't be protected for reflection access reasons so some of the tidy wasn't so tidy.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@388 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
package com.threerings.stats.server.persist;
|
||||||
|
|
||||||
|
import com.samskivert.jdbc.depot.PersistentRecord;
|
||||||
|
import com.samskivert.jdbc.depot.annotation.Column;
|
||||||
|
import com.samskivert.jdbc.depot.annotation.Computed;
|
||||||
|
import com.samskivert.jdbc.depot.annotation.Entity;
|
||||||
|
import com.samskivert.jdbc.depot.expression.ColumnExp;
|
||||||
|
|
||||||
|
@Computed @Entity
|
||||||
|
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);
|
||||||
|
// AUTO-GENERATED: FIELDS END
|
||||||
|
|
||||||
|
@Column
|
||||||
|
public int maxCode;
|
||||||
|
}
|
||||||
@@ -21,8 +21,6 @@ import com.samskivert.jdbc.depot.DepotRepository;
|
|||||||
import com.samskivert.jdbc.depot.PersistenceContext.CacheEvictionFilter;
|
import com.samskivert.jdbc.depot.PersistenceContext.CacheEvictionFilter;
|
||||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||||
import com.samskivert.jdbc.depot.PersistentRecord;
|
import com.samskivert.jdbc.depot.PersistentRecord;
|
||||||
import com.samskivert.jdbc.depot.annotation.Computed;
|
|
||||||
import com.samskivert.jdbc.depot.annotation.Entity;
|
|
||||||
import com.samskivert.jdbc.depot.clause.FieldOverride;
|
import com.samskivert.jdbc.depot.clause.FieldOverride;
|
||||||
import com.samskivert.jdbc.depot.clause.FromOverride;
|
import com.samskivert.jdbc.depot.clause.FromOverride;
|
||||||
import com.samskivert.jdbc.depot.clause.QueryClause;
|
import com.samskivert.jdbc.depot.clause.QueryClause;
|
||||||
@@ -229,7 +227,8 @@ public class StatRepository extends DepotRepository
|
|||||||
MaxStatCodeRecord maxRecord = load(
|
MaxStatCodeRecord maxRecord = load(
|
||||||
MaxStatCodeRecord.class,
|
MaxStatCodeRecord.class,
|
||||||
new FromOverride(StringCodeRecord.class),
|
new FromOverride(StringCodeRecord.class),
|
||||||
new FieldOverride("maxCode", new FunctionExp("MAX", StringCodeRecord.CODE_C)),
|
new FieldOverride(MaxStatCodeRecord.MAX_CODE,
|
||||||
|
new FunctionExp("MAX", StringCodeRecord.CODE_C)),
|
||||||
new Where(StringCodeRecord.STAT_CODE_C, type.code()));
|
new Where(StringCodeRecord.STAT_CODE_C, type.code()));
|
||||||
|
|
||||||
int code = maxRecord != null ? maxRecord.maxCode + 1 : 1;
|
int code = maxRecord != null ? maxRecord.maxCode + 1 : 1;
|
||||||
@@ -311,11 +310,6 @@ public class StatRepository extends DepotRepository
|
|||||||
classes.add(StringCodeRecord.class);
|
classes.add(StringCodeRecord.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Computed @Entity
|
|
||||||
protected static class MaxStatCodeRecord extends PersistentRecord {
|
|
||||||
int maxCode;
|
|
||||||
};
|
|
||||||
|
|
||||||
protected HashMap<Stat.Type,HashMap<String,Integer>> _stringToCode =
|
protected HashMap<Stat.Type,HashMap<String,Integer>> _stringToCode =
|
||||||
new HashMap<Stat.Type,HashMap<String,Integer>>();
|
new HashMap<Stat.Type,HashMap<String,Integer>>();
|
||||||
protected HashMap<Stat.Type,HashIntMap<String>> _codeToString =
|
protected HashMap<Stat.Type,HashIntMap<String>> _codeToString =
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ public class StringCodeRecord extends PersistentRecord
|
|||||||
* Create and return a primary {@link Key} to identify a {@link #StringCodeRecord}
|
* Create and return a primary {@link Key} to identify a {@link #StringCodeRecord}
|
||||||
* with the supplied key values.
|
* with the supplied key values.
|
||||||
*/
|
*/
|
||||||
public static Key<StringCodeRecord> getKey (int statCode, String value, int code)
|
public static Key<StringCodeRecord> getKey (int statCode, String value)
|
||||||
{
|
{
|
||||||
return new Key<StringCodeRecord>(
|
return new Key<StringCodeRecord>(
|
||||||
StringCodeRecord.class,
|
StringCodeRecord.class,
|
||||||
new String[] { STAT_CODE, VALUE, CODE },
|
new String[] { STAT_CODE, VALUE },
|
||||||
new Comparable[] { statCode, value, code });
|
new Comparable[] { statCode, value });
|
||||||
}
|
}
|
||||||
// AUTO-GENERATED: METHODS END
|
// AUTO-GENERATED: METHODS END
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user