private void processJoin(ExpressionBuilderHelper h, QueryCompilation compilation, FetchPlan fetchPlan, boolean hasWhere) { if (compilation.getExprFrom() == null) return; for (Expression fromExpr : compilation.getExprFrom()) { if (!(fromExpr instanceof ClassExpression)) { throw new NucleusDataStoreException("Unsupported from expression: " + fromExpr); } Expression expr = fromExpr.getRight(); while (expr != null) { if (expr instanceof JoinExpression) { JoinExpression je = (JoinExpression) expr; processJoinExpression(je.getPrimaryExpression(), je.getAlias(), h, compilation, true, hasWhere, false); h.sb.append("))"); // Either this was already true or will be after the first call hasWhere = true; } else { throw new NucleusDataStoreException("Unsupported expression found inside a join expression: " + fromExpr.getRight()); } expr = expr.getRight(); } } }
private void processFromExpression(QueryData qd, Expression expr) { if (expr instanceof JoinExpression) { JoinExpression joinExpr = (JoinExpression) expr; if (joinExpr.getType() != JoinExpression.JoinType.JOIN_INNER && joinExpr.getType() != JoinExpression.JoinType.JOIN_INNER_FETCH) { throw new UnsupportedDatastoreFeatureException("Cannot fulfill outer join queries."); } qd.joinOrderExpression = createJoinOrderExpression(joinExpr.getPrimaryExpression()); } if (expr.getLeft() != null) { processFromExpression(qd, expr.getLeft()); } if (expr.getRight() != null) { processFromExpression(qd, expr.getRight()); } }
tuples.add(attr.getName()); PrimaryExpression primExpr = new PrimaryExpression(new ArrayList(tuples)); JoinExpression joinExpr = new JoinExpression(primExpr, join.getAlias(), jt); if (currentExpr instanceof ClassExpression) ((JoinExpression)currentExpr).setJoinExpression(joinExpr); tuples.add(attr.getName()); PrimaryExpression primExpr = new PrimaryExpression(new ArrayList(tuples)); JoinExpression joinExpr = new JoinExpression(primExpr, null, jt); if (currentExpr instanceof ClassExpression) ((JoinExpression)currentExpr).setJoinExpression(joinExpr);
JoinExpression.JoinType exprJoinType = joinExpr.getType(); JoinType joinType = org.datanucleus.store.rdbms.sql.SQLJoin.getJoinTypeForJoinExpressionType(exprJoinType); Expression joinedExpr = joinExpr.getJoinedExpression(); Expression joinOnExpr = joinExpr.getOnExpression(); String joinAlias = joinExpr.getAlias();
private PrimaryExpression getPrimaryExpresionFromJoinAlias(QueryCompilation compilation, String alias) { for (Expression fromExpr : compilation.getExprFrom()) { for (Expression expr = fromExpr.getRight(); expr != null; expr = expr.getRight()) { if (expr instanceof JoinExpression && alias.equals(expr.getAlias())) { return ((JoinExpression) expr).getPrimaryExpression(); } } } return null; }
private PrimaryExpression getPrimaryExpresionFromJoinAlias(QueryCompilation compilation, String alias) { for (Expression fromExpr : compilation.getExprFrom()) { for (Expression expr = fromExpr.getRight(); expr != null; expr = expr.getRight()) { if (expr instanceof JoinExpression && alias.equals(expr.getAlias())) { return ((JoinExpression) expr).getPrimaryExpression(); } } } return null; }
private void processJoin(ExpressionBuilderHelper h, QueryCompilation compilation, FetchPlan fetchPlan, boolean hasWhere) { if (compilation.getExprFrom() == null) return; for (Expression fromExpr : compilation.getExprFrom()) { if (!(fromExpr instanceof ClassExpression)) { throw new NucleusDataStoreException("Unsupported from expression: " + fromExpr); } Expression expr = fromExpr.getRight(); while (expr != null) { if (expr instanceof JoinExpression) { JoinExpression je = (JoinExpression) expr; processJoinExpression(je.getPrimaryExpression(), je.getAlias(), h, compilation, true, hasWhere, false); h.sb.append("))"); // Either this was already true or will be after the first call hasWhere = true; } else { throw new NucleusDataStoreException("Unsupported expression found inside a join expression: " + fromExpr.getRight()); } expr = expr.getRight(); } } }
for (Expression expr = fromExpr.getRight(); expr != null; expr = expr.getRight()) { if (expr instanceof JoinExpression && mappingAliases.contains(expr.getAlias())) { List<String> t = ((JoinExpression) expr).getPrimaryExpression().getTuples(); relatedJoinAliases.put(new TupleName(t), expr.getAlias());
for (Expression expr = fromExpr.getRight(); expr != null; expr = expr.getRight()) { if (expr instanceof JoinExpression && mappingAliases.contains(expr.getAlias())) { List<String> t = ((JoinExpression) expr).getPrimaryExpression().getTuples(); relatedJoinAliases.put(new TupleName(t), expr.getAlias());