use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class RetrieveDescImpl method buildQueryPlan.
/**
* Builds the internal query plan and initializes the select statements.
* Projections on collection fields will not be resolved until the actual
* retrieval in {@link SQLStoreManager#retrieve(
* com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager,
* RetrieveDesc, com.sun.jdo.spi.persistence.support.sqlstore.ValueFetcher)}.
*/
public synchronized SelectQueryPlan buildQueryPlan(SQLStoreManager store, Concurrency concurrency) {
if (plan == null) {
handleProjection();
plan = SelectQueryPlan.newInstance(this, store, concurrency);
plan.build();
// Generate the text for the select statements.
ArrayList statements = plan.getStatements();
// Sanity check.
if (statements.size() > 1) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"sqlstore.retrievedesc.stmntsnotjoined"));
}
}
return plan;
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class SelectQueryPlan method processForeignFieldConstraint.
/**
* Joins the current plan with the constraint <code>node</code>. The constraint
* includes the name of the parent field and the retrieve descriptor for the
* related class. The plans will be joined with <code>OP_EQUIJOIN</code>.
* The constraints processed here have been added by
* {@link RetrieveDesc#addConstraint(String, RetrieveDesc)}.
*
* @param node Join constraint.
*/
private void processForeignFieldConstraint(ConstraintForeignFieldName node) {
RetrieveDescImpl rd = (RetrieveDescImpl) node.desc;
if (rd == null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"sqlstore.constraint.noretrievedesc", node.name, config.getPersistenceCapableClass().getName()));
}
SelectQueryPlan fcp = newForeignConstraintPlan(rd, node.name);
if ((fcp.status & ST_JOINED) == 0) {
fcp.processParentField(config, node.name);
// Joins on constraints always join as equijoin
processJoin(fcp, ActionDesc.OP_EQUIJOIN);
fcp.appendAndOp = true;
} else {
fcp.appendAndOp = false;
}
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class Statement method processConstraintField.
private void processConstraintField(ConstraintField fieldNode, StringBuffer result) {
LocalFieldDesc desc = null;
QueryPlan thePlan = getOriginalPlan(fieldNode);
if (fieldNode instanceof ConstraintFieldDesc) {
desc = ((ConstraintFieldDesc) fieldNode).desc;
} else if (fieldNode instanceof ConstraintFieldName) {
desc = thePlan.config.getLocalFieldDesc(((ConstraintFieldName) fieldNode).name);
} else {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.generic.notinstanceof", fieldNode.getClass().getName(), // NOI18N
"ConstraintFieldDesc/ConstraintFieldName"));
}
generateColumnText(desc, thePlan, result);
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class Statement method processConstraints.
/**
* Processes the constraint stack and adds it to the query.
* This means turning the constraint stack into SQL text and
* adding it to the where clause.
*
* @return Where clause based on the constraint stack.
*/
public StringBuffer processConstraints() {
StringBuffer whereText = new StringBuffer();
List stack = constraint.getConstraints();
while (stack.size() > 0) {
ConstraintNode node = (ConstraintNode) stack.get(stack.size() - 1);
if (!(node instanceof ConstraintOperation)) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.generic.notinstanceof", node.getClass().getName(), // NOI18N
"ConstraintOperation"));
}
processRootConstraint((ConstraintOperation) node, stack, whereText);
}
return whereText;
}
use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.
the class Statement method operationFormat.
protected int operationFormat(int operation) {
int format = 0;
switch(operation) {
// Binary operators
case ActionDesc.OP_EQ:
case ActionDesc.OP_NE:
case ActionDesc.OP_GT:
case ActionDesc.OP_GE:
case ActionDesc.OP_LT:
case ActionDesc.OP_LE:
case ActionDesc.OP_AND:
case ActionDesc.OP_MUL:
case ActionDesc.OP_LIKE:
format = OP_BINOP_MASK;
break;
// Binary operators that require Parenthesis
case ActionDesc.OP_ADD:
case ActionDesc.OP_SUB:
case ActionDesc.OP_DIV:
case ActionDesc.OP_OR:
format = OP_BINOP_MASK | OP_PAREN_MASK;
break;
// Functions
case ActionDesc.OP_ABS:
case ActionDesc.OP_SQRT:
case ActionDesc.OP_LENGTH:
case ActionDesc.OP_LTRIM:
case ActionDesc.OP_NOT:
case ActionDesc.OP_NULL_COMPARISION_FUNCTION:
format = OP_FUNC_MASK;
break;
// Irregular operators
case ActionDesc.OP_BETWEEN:
case ActionDesc.OP_LIKE_ESCAPE:
case ActionDesc.OP_IN:
case ActionDesc.OP_NOTIN:
case ActionDesc.OP_NULL:
case ActionDesc.OP_NOTNULL:
case ActionDesc.OP_MAYBE_NULL:
case ActionDesc.OP_CONCAT:
case ActionDesc.OP_EQUIJOIN:
format = OP_IRREGULAR_MASK | OP_WHERE_MASK;
break;
// Hence they do not have OP_WHERE_MASK set.
case ActionDesc.OP_SUBSTRING:
case ActionDesc.OP_POSITION:
case ActionDesc.OP_POSITION_START:
format = OP_IRREGULAR_MASK;
break;
case ActionDesc.OP_NOTEXISTS:
case ActionDesc.OP_EXISTS:
format = OP_IRREGULAR_MASK | OP_WHERE_MASK | OP_PREFIX_MASK;
break;
case ActionDesc.OP_MOD:
format = vendorType.isModOperationUsingFunction() ? OP_IRREGULAR_MASK : OP_BINOP_MASK | OP_PAREN_MASK;
break;
case ActionDesc.OP_DISTINCT:
format = OP_OTHER_MASK;
break;
case ActionDesc.OP_ORDERBY:
case ActionDesc.OP_ORDERBY_DESC:
format = OP_ORDERBY_MASK;
break;
case ActionDesc.OP_RTRIM:
case ActionDesc.OP_RTRIMFIXED:
if (vendorType.isAnsiTrim()) {
format = OP_WHERE_MASK | OP_PREFIX_MASK | OP_POSTFIX_MASK | OP_PARAM_MASK;
} else {
format = OP_FUNC_MASK;
}
break;
// TODO: Check how can this masks be optimized
case ActionDesc.OP_LEFTJOIN:
format = OP_IRREGULAR_MASK | OP_WHERE_MASK | OP_INFIX_MASK;
format = format | OP_POSTFIX_MASK;
break;
case ActionDesc.OP_RIGHTJOIN:
format = OP_IRREGULAR_MASK | OP_WHERE_MASK | OP_INFIX_MASK;
format = format | OP_PREFIX_MASK;
break;
default:
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"core.constraint.illegalop", // NOI18N
"" + operation));
}
return format;
}
Aggregations