FileDocCategorySizeDatePackage
ConcurrencyCheckDirty.javaAPI DocGlassfish v2 API6365Fri May 04 22:35:12 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.sql.concurrency

ConcurrencyCheckDirty

public class ConcurrencyCheckDirty extends ConcurrencyDBNative

Fields Summary
Constructors Summary
Methods Summary
private static voidaddConstraint(com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.UpdateQueryPlan plan, com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc lf, java.lang.Object val)
Adds a comparison for local field lf and value val to the corresponding statements in UpdateQueryPlan plan.

        for (Iterator iter = lf.getColumnElements(); iter.hasNext(); ) {
            ColumnElement c = (ColumnElement) iter.next();

            for (int i = 0; i < plan.statements.size(); i++) {
                Statement s = (Statement) plan.statements.get(i);

                for (int j = 0; j < s.tableList.size(); j++) {
                    QueryTable t = (QueryTable) s.tableList.get(j);

                    if (t.getTableDesc().getTableElement() == c.getDeclaringTable()) {
                        s.addConstraint(lf, val);
                    }
                }
            }
        }
    
public java.lang.Objectclone()

        return new ConcurrencyCheckDirty();
    
public voidcommit(com.sun.jdo.spi.persistence.support.sqlstore.UpdateObjectDesc updateDesc, com.sun.jdo.spi.persistence.support.sqlstore.SQLStateManager beforeImage, com.sun.jdo.spi.persistence.support.sqlstore.SQLStateManager afterImage, int logReason)

        this.beforeImage = beforeImage;
        this.afterImage = afterImage;
    
protected booleanisFieldVerificationRequired(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc lf, java.util.BitSet verifyGroupMask)

         return true;
    
protected java.util.BitSetprepareVerifyGroupMask(com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.UpdateQueryPlan plan)

        return null;
    
public voidupdate(com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.UpdateQueryPlan plan)

        boolean debug = logger.isLoggable();

        if (debug) {
            logger.fine("sqlstore.sql.concurrency.concurrencychkdirty", beforeImage); // NOI18N
        }

        if (beforeImage != null) {
            ArrayList fields = plan.getConfig().fields;
            BitSet verifyGroupMask = prepareVerifyGroupMask(plan);

            for (int i = 0; i < 2; i++) {

                if (i == 0) {
                    fields = plan.getConfig().fields;
                } else if (i == 1) {
                    fields = plan.getConfig().hiddenFields;
                }

                if (fields == null) {
                    continue;
                }

                for (int j = 0; j < fields.size(); j++) {
                    FieldDesc f = (FieldDesc) fields.get(j);

                    if (f instanceof LocalFieldDesc) {
                        LocalFieldDesc lf = (LocalFieldDesc) f;

                        // Make sure the field is marked for concurrency check and is present
                        // Also, skip all fields that are marked as secondary tracked fields.
                        //
                        // RESOLVE: we need to fetch the fields that are not present.
                        if (((lf.sqlProperties & FieldDesc.PROP_IN_CONCURRENCY_CHECK) > 0) &&
                                ((lf.sqlProperties & FieldDesc.PROP_SECONDARY_TRACKED_FIELD) == 0) &&
                                beforeImage.getPresenceMaskBit(lf.absoluteID)) {

                            if (isFieldVerificationRequired(lf, verifyGroupMask)) {
                                Object val = null;
                                val = lf.getValue(this.beforeImage);
                                addConstraint(plan, lf, val);
                            }
                        }
                    }
                }
            }
        }

        if (debug) {
            logger.fine("sqlstore.sql.concurrency.concurrencychkdirty.exit"); // NOI18N
        }