use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class SelectQueryPlan method addCorrelatedInQuery.
/**
* Creates and builds a correlated "In" subquery.
* Merges tables from the subquery plan to the current plan and adds
* the local fields corresponding to the subquery to the constaints.
* The subquery is added to the constraint stack.
*
* @param node subquery constraint.
*/
private void addCorrelatedInQuery(ConstraintFieldNameSubQuery node) {
FieldDesc field = config.getField(node.fieldName);
RetrieveDescImpl rd = (RetrieveDescImpl) node.desc;
if (field != null && field instanceof ForeignFieldDesc) {
ForeignFieldDesc ff = (ForeignFieldDesc) field;
if (ff.getComponentType() != rd.getPersistenceCapableClass()) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.unknownfield", node.fieldName, rd.getPersistenceCapableClass().getName()));
}
SelectQueryPlan subqueryPlan = new CorrelatedInSelectPlan(rd, store, ff, this);
subqueryPlan.build();
// Make the tables involved in the subquery known to the parent query.
addQueryTables(subqueryPlan.tables);
// Push a new subquery constraint on the stack
ConstraintSubquery subqueryConstraint = new ConstraintSubquery();
subqueryConstraint.plan = subqueryPlan;
constraint.stack.add(subqueryConstraint);
ArrayList localFields = ff.getLocalFields();
// Add the local fields corresponding to the subquery to the stack.
for (int i = 0; i < localFields.size(); i++) {
constraint.addField((LocalFieldDesc) localFields.get(i), this);
}
} else {
// or the field is not present in the config.
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.unknownfield", node.fieldName, rd.getPersistenceCapableClass().getName()));
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class SelectQueryPlan method processParentField.
/**
* Sets the plan's parent field and adds the tables for the join columns
* to the table list. The parent field is identified by <code>fieldName</code>
* and defined in the model information of the parent class
* <code>parentConfig</code>.
*
* @see ClassDesc
*/
private void processParentField(ClassDesc parentConfig, String fieldName) {
if (parentField == null) {
// The plan has not been processed before
FieldDesc f = parentConfig.getField(fieldName);
if (f == null || !(f instanceof ForeignFieldDesc)) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.unknownfield", fieldName, parentConfig.getPersistenceCapableClass().getName()));
}
parentField = (ForeignFieldDesc) f;
// Add the join table, if neccessary.
if (parentField.useJoinTable()) {
//
for (int i = 0; i < parentField.assocLocalColumns.size(); i++) {
ColumnElement col = (ColumnElement) parentField.assocLocalColumns.get(i);
addQueryTable(col.getDeclaringTable(), config);
}
}
// The side-effect for this is to create statements with no columns.
for (int i = 0; i < parentField.foreignColumns.size(); i++) {
ColumnElement col = (ColumnElement) parentField.foreignColumns.get(i);
addQueryTable(col.getDeclaringTable(), config);
}
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class SelectStatement method processRootConstraint.
/**
* Processes Order By constraints and calls the super class
* method for all other constrains.
*/
protected void processRootConstraint(ConstraintOperation opNode, List stack, StringBuffer whereText) {
int op = opNode.operation;
int opInfo = operationFormat(op);
if ((opInfo & OP_ORDERBY_MASK) > 0) {
stack.remove(stack.size() - 1);
ConstraintNode node = (ConstraintNode) stack.get(stack.size() - 1);
if (!(node instanceof ConstraintField)) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.needfieldnode"));
} else {
processOrderByField((ConstraintFieldDesc) node, op);
stack.remove(stack.size() - 1);
}
} else {
super.processRootConstraint(opNode, stack, whereText);
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class Statement method processRootConstraint.
protected void processRootConstraint(ConstraintOperation opNode, List stack, StringBuffer whereText) {
int op = opNode.operation;
int opInfo = operationFormat(op);
if ((opInfo & OP_WHERE_MASK) > 0) {
String constraint = getWhereText(stack);
if (whereText.length() > 0 && constraint.length() > 0) {
// This is neccessary, if the constraint stack is "un-balanced",
// see OrderingTest#ordering006 for an example.
whereText.append(" and ");
}
whereText.append(constraint);
} else {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "sqlstore.sql.generator.statement.unexpectedconstraint", // NOI18N
op));
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException 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);
}
Aggregations