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");
}
}
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;
}
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);
}
}
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);
}
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));
}
}
}
Aggregations