Search in sources :

Example 1 with LocalFieldDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc in project Payara by payara.

the class ConcurrencyCheckDirty method update.

public void update(UpdateQueryPlan plan) {
    boolean debug = logger.isLoggable();
    if (debug) {
        // NOI18N
        logger.fine("sqlstore.sql.concurrency.concurrencychkdirty", beforeImage);
    }
    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;
                    // 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) {
        // NOI18N
        logger.fine("sqlstore.sql.concurrency.concurrencychkdirty.exit");
    }
}
Also used : LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc) ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) FieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.FieldDesc) LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc)

Example 2 with LocalFieldDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc in project Payara by payara.

the class ConcurrencyOptVerify method prepareVerifyGroupMask.

/**
 * Find all the local fields that have been updated
 * and use their concurrencyGroup to set the verifyGroupMask.
 */
protected BitSet prepareVerifyGroupMask(UpdateQueryPlan plan) {
    ArrayList fields;
    BitSet verifyGroupMask = new BitSet();
    int action = plan.getAction();
    for (int i = 0; i <= 1; i++) {
        if (i == 0) {
            fields = plan.getConfig().fields;
        } else {
            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) && (f.sqlProperties & FieldDesc.PROP_IN_CONCURRENCY_CHECK) > 0) {
                // the concurrency check.
                if (afterImage.getSetMaskBit(f.absoluteID) || ((action == QueryPlan.ACT_DELETE) && beforeImage.getPresenceMaskBit(f.absoluteID))) {
                    if (f.concurrencyGroup != -1) {
                        verifyGroupMask.set(f.concurrencyGroup);
                    }
                }
            }
        }
    }
    return verifyGroupMask;
}
Also used : LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc) ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) FieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.FieldDesc) LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc)

Example 3 with LocalFieldDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc in project Payara by payara.

the class CorrelatedExistSelectPlan method doCorrelatedJoin.

/**
 * The correlated constraint joining this subquery with the parent field.
 * The joined table is added as a side-effect.
 */
protected void doCorrelatedJoin() {
    ArrayList foreignFields = null;
    if (parentField.useJoinTable()) {
        foreignFields = parentField.assocLocalFields;
    // The join table is included in #processJoinTable
    } else {
        foreignFields = parentField.foreignFields;
    }
    ArrayList localFields = parentField.localFields;
    // Add the constraint linking the parent query with the subquery.
    for (int i = 0; i < localFields.size(); i++) {
        LocalFieldDesc la = (LocalFieldDesc) localFields.get(i);
        LocalFieldDesc fa = (LocalFieldDesc) foreignFields.get(i);
        ConstraintFieldDesc lcfd = new ConstraintFieldDesc(la, parentPlan);
        ConstraintFieldDesc fcfd = new ConstraintFieldDesc(fa, this);
        constraint.addField(lcfd);
        constraint.addField(fcfd);
        // Subqueries always join via equijoin.
        constraint.addOperation(ActionDesc.OP_EQ);
    }
}
Also used : ConstraintFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.ConstraintFieldDesc) LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc) ArrayList(java.util.ArrayList)

Example 4 with LocalFieldDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc in project Payara by payara.

the class Statement method processNullOperation.

private void processNullOperation(int opCode, List stack, StringBuffer result) {
    String nullComparisionFunctionName = vendorType.getNullComparisonFunctionName();
    if (nullComparisionFunctionName.length() != 0) {
        // Null comparision for LOB type fields is
        // through function for this DB
        Object nextNode = stack.get(stack.size() - 1);
        if (nextNode != null) {
            if (nextNode instanceof ConstraintFieldName) {
                ConstraintFieldName fieldNode = (ConstraintFieldName) nextNode;
                QueryPlan originalPlan = getQueryPlan();
                if (fieldNode.originalPlan != null) {
                    originalPlan = fieldNode.originalPlan;
                }
                LocalFieldDesc desc = (LocalFieldDesc) originalPlan.config.getField(fieldNode.name);
                if (desc.isMappedToLob()) {
                    // Add a dummy ConstraintOperation Node corresponding
                    // to null comparision func.
                    stack.add(new ConstraintOperation(ActionDesc.OP_NULL_COMPARISION_FUNCTION));
                }
            }
        } else {
            throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
            "core.constraint.stackempty"));
        }
    }
    result.append(getWhereText(stack));
    String str = (opCode == ActionDesc.OP_NULL) ? vendorType.getIsNull() : vendorType.getIsNotNull();
    result.append(str);
}
Also used : LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc) JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException)

Example 5 with LocalFieldDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc in project Payara by payara.

the class UpdateStatement method addForeignConstraints.

public void addForeignConstraints(int action, ForeignFieldDesc f, SQLStateManager sm) {
    for (int i = 0; i < f.foreignFields.size(); i++) {
        LocalFieldDesc ff = (LocalFieldDesc) f.foreignFields.get(i);
        if (action == QueryPlan.ACT_INSERT) {
            // For inserts into the join table, we get the values we are inserting
            // for the parent object and the added object.
            ColumnElement fc = (ColumnElement) f.assocForeignColumns.get(i);
            addColumn(fc, ff.getValue(sm));
        } else if (action == QueryPlan.ACT_DELETE) {
            LocalFieldDesc aff = (LocalFieldDesc) f.assocForeignFields.get(i);
            // For deletes from the join table, we get the constraint values
            // from the parent object and the remove object.
            addConstraint(aff, ff.getValue(sm));
        }
    }
}
Also used : LocalFieldDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc) ColumnElement(org.netbeans.modules.dbschema.ColumnElement)

Aggregations

LocalFieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc)14 FieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.FieldDesc)3 ArrayList (java.util.ArrayList)3 ColumnElement (org.netbeans.modules.dbschema.ColumnElement)3 JDOFatalInternalException (com.sun.jdo.api.persistence.support.JDOFatalInternalException)2 ForeignFieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.ForeignFieldDesc)2 BitSet (java.util.BitSet)2 ClassDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc)1 Constraint (com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.Constraint)1 ConstraintFieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.ConstraintFieldDesc)1