Package com.samskivert.depot.clause

Examples of com.samskivert.depot.clause.Where


     * @return the modified Stat, if any modification took place; or null if the modification had
     * no effect on the stat's data.
     */
    public <T extends Stat> T updateStat (int playerId, StatModifier<T> modifier)
    {
        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() :
View Full Code Here


     *
     */
    public ArrayList<Stat> loadStats (int playerId)
    {
        ArrayList<Stat> stats = Lists.newArrayList();
        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) {
                stats.add(stat);
            }
View Full Code Here

    /**
     * Deletes all stats associated with the specified player.
     */
    public void deleteStats (final int playerId)
    {
        deleteAll(StatRecord.class, new Where(StatRecord.PLAYER_ID, playerId));
    }
View Full Code Here

    /**
     * Deletes all data associated with the supplied players.
     */
    public void purgePlayers (Collection<Integer> playerIds)
    {
        deleteAll(StatRecord.class, new Where(StatRecord.PLAYER_ID.in(playerIds)));
    }
View Full Code Here

        Key<StatRecord> key = StatRecord.getKey(playerId, stat.getCode());

        // update the row in the database only if it has the expected modCount
        int numRows = updatePartial(
            StatRecord.class,
            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);
View Full Code Here

        for (int ii = 0; ii < 10; ii++) {
            MaxStatCodeRecord maxRecord = load(
                MaxStatCodeRecord.class,
                new FromOverride(StringCodeRecord.class),
                new FieldDefinition(MaxStatCodeRecord.MAX_CODE, Funcs.max(StringCodeRecord.CODE)),
                new Where(StringCodeRecord.STAT_CODE, type.code()));

            int code = maxRecord != null ? maxRecord.maxCode + 1 : 1;

            // DEBUG: uncomment this to test code collision
            // if (ii == 0 && code > 0) {
View Full Code Here

    /** Helper function used at repository startup. */
    protected void loadStringCodes (Stat.Type type)
    {
        QueryClause[] clauses;
        if (type != null) {
            clauses = new QueryClause[] { new Where(StringCodeRecord.STAT_CODE, type.code()) };
        } else {
            clauses = new QueryClause[0];
        }

        for (StringCodeRecord record : findAll(StringCodeRecord.class, clauses)) {
View Full Code Here

TOP

Related Classes of com.samskivert.depot.clause.Where

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.