コード例 #1
0
  protected Expression processPropertyTracedownTooneOptimized(
      Attribute<?, ?> attr, Expression builder, List<Parameter> parameters) {
    ConditionQuery subQuery = getTraceDownQuery();

    Expression finalExp = null;
    for (PropertyCondition subPc : subQuery.getConditions()) {
      if (subPc.isReturnSimpleExpression()) {
        Expression subExp = subPc.processProperty(builder.get(getProp()), parameters);
        if (finalExp == null) {
          finalExp = subExp;
        } else {
          finalExp = finalExp.and(subExp);
        }
      } else {
        // low-performance query since an extra layer of exists added
        // but this is the only way to make it work.
        // this situation is rare. So we may do not need to optimize it
        Expression subBuilder = new ExpressionBuilder();
        Expression subExp = subPc.processProperty(subBuilder, parameters);
        ReportQuery childQuery = formRelationReportQuery(attr, subBuilder);
        childQuery.retrievePrimaryKeys();
        childQuery.setSelectionCriteria(subBuilder.equal(builder.get(getProp())).and(subExp));
        if (finalExp == null) {
          finalExp = builder.exists(childQuery);
        } else {
          finalExp = finalExp.and(builder.exists(childQuery));
        }
      }
    }
    return finalExp;
  }
コード例 #2
0
  protected boolean isComplexTracedown(Attribute<?, ?> attr) {
    ConditionQuery subQuery = getTraceDownQuery();

    for (PropertyCondition subPc : subQuery.getConditions()) {
      if (!subPc.isReturnSimpleExpression()) {
        return false;
      }
    }
    return true;
  }
コード例 #3
0
  protected Expression processPropertyTracedownToManyNone(
      Attribute<?, ?> attr, Expression builder, List<Parameter> parameters) {
    ConditionQuery subQuery = getTraceDownQuery();
    // subQuery.setPrefix(getQuery().getPrefix()+parameters.size()+"_");
    Expression subBuilder = new ExpressionBuilder();
    List<Expression> childExps = new ArrayList<Expression>(3);
    for (PropertyCondition subPc : subQuery.getConditions()) {
      Expression subExp = subPc.processProperty(subBuilder, parameters);
      childExps.add(subExp);
    }
    if (childExps.isEmpty()) {
      throw new InvalidQueryException("No expression from subquery.");
    }
    Expression finalExp = childExps.get(0);

    for (int i = 1; i < childExps.size(); i++) {
      finalExp = finalExp.and(childExps.get(i));
    }

    return builder.noneOf(getProp(), finalExp);
  }
コード例 #4
0
  protected Expression processPropertyTracedownToManySomeOptimized(
      Attribute<?, ?> attr, Expression builder, List<Parameter> parameters) {
    ConditionQuery subQuery = getTraceDownQuery();
    // subQuery.setPrefix(getQuery().getPrefix()+parameters.size()+"_");
    Expression prefixExp = builder.anyOf(getProp());

    List<Expression> complexExps = new ArrayList<Expression>();

    for (PropertyCondition subPc : subQuery.getConditions()) {
      Expression subExp = subPc.processProperty(prefixExp, parameters);
      complexExps.add(subExp);
    }
    Expression finalExp = null;
    if (complexExps.isEmpty()) {
      throw new InvalidQueryException("No expression from subquery.");
    }
    finalExp = complexExps.get(0);
    for (int i = 1; i < complexExps.size(); i++) {
      finalExp = finalExp.and(complexExps.get(i));
    }
    return finalExp;
  }