/** * INTERNAL: * Search the tree for any expressions (like SubSelectExpressions) that have been * built using a builder that is not attached to the query. This happens in case of an Exists * call using a new ExpressionBuilder(). This builder needs to be replaced with one from the query. */ public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder){ if (getBaseExpression() != null){ getBaseExpression().resetPlaceHolderBuilder(queryBuilder); } }
protected Expression resolveBaseExpression(Expression expression) { Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); //filter out aggregate expressions between this and the next node. while (!baseExpression.isExpressionBuilder() && ((QueryKeyExpression)baseExpression).getMapping().isAggregateMapping()){ baseExpression = ((BaseExpression)baseExpression).getBaseExpression(); } return baseExpression; }
/** * PUBLIC: A logical expression for the size of collection expression. * <p>Example: * <blockquote><pre> * EclipseLink: employee.size(Class returnType) * Java: employee.getPhoneNumbers().size() * SQL: SELECT ... FROM EMP t0 WHERE ... * (SELECT COUNT(*) FROM PHONE t1 WHERE (t0.EMP_ID = t1.EMP_ID)) * </pre></blockquote> * This is a case where a fast operation in java does not translate to an * equally fast operation in SQL, requiring a correlated subselect. */ public Expression size(Class returnType) { if (((BaseExpression)this).getBaseExpression() == null){ return SubSelectExpression.createSubSelectExpressionForCount(this, this, null, returnType); } return SubSelectExpression.createSubSelectExpressionForCount(((BaseExpression)this).getBaseExpression(), this, null, returnType); }
/** * PUBLIC: A logical expression for the size of collection expression. * <p>Example: * <blockquote><pre> * EclipseLink: employee.size(Class returnType) * Java: employee.getPhoneNumbers().size() * SQL: SELECT ... FROM EMP t0 WHERE ... * (SELECT COUNT(*) FROM PHONE t1 WHERE (t0.EMP_ID = t1.EMP_ID)) * </pre></blockquote> * This is a case where a fast operation in java does not translate to an * equally fast operation in SQL, requiring a correlated subselect. */ public Expression size(Class returnType) { if (((BaseExpression)this).getBaseExpression() == null){ return SubSelectExpression.createSubSelectExpressionForCount(this, this, null, returnType); } return SubSelectExpression.createSubSelectExpressionForCount(((BaseExpression)this).getBaseExpression(), this, null, returnType); }
public void addJoinedAttributeExpression(Expression attributeExpression) { if(!getJoinedAttributeExpressions().contains(attributeExpression)) { if((attributeExpression instanceof BaseExpression)) { Expression baseExpression = ((BaseExpression)attributeExpression).getBaseExpression(); if(baseExpression != null && !baseExpression.isExpressionBuilder()) { addJoinedAttributeExpression(baseExpression); } } getJoinedAttributeExpressions().add(attributeExpression); } }
boolean sameBase = false;//better than using instanceof BaseExpression. If its not an objectExpression, it will get an exception in prepare anyway if((expression.isObjectExpression())) { Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); baseExpression = ((BaseExpression)baseExpression).getBaseExpression();
boolean sameBase = false;//better than using instanceof BaseExpression. If its not an objectExpression, it will get an exception in prepare anyway if((expression.isObjectExpression())) { Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); baseExpression = ((BaseExpression)baseExpression).getBaseExpression();
/** * PUBLIC: A logical expression for the size of collection expression. * <p>Example: * <pre><blockquote> * TopLink: employee.size(Class returnType) * Java: employee.getPhoneNumbers().size() * SQL: SELECT ... FROM EMP t0 WHERE ... * (SELECT COUNT(*) FROM PHONE t1 WHERE (t0.EMP_ID = t1.EMP_ID)) * </blockquote></pre> * This is a case where a fast operation in java does not translate to an * equally fast operation in SQL, requiring a correlated subselect. */ public Expression size(Class returnType) { // Create an anonymous subquery that will get its reference class // set during SubSelectExpression.normalize. ReportQuery subQuery = new ReportQuery(); subQuery.addCount("COUNT", subQuery.getExpressionBuilder(), returnType); subQuery.setSelectionCriteria(subQuery.getExpressionBuilder().equal(this)); if (((BaseExpression)this).getBaseExpression() == null){ return this.subQuery(subQuery); } return ((BaseExpression)this).getBaseExpression().subQuery(subQuery); }
SubSelectExpression sub = new SubSelectExpression(subSelect, ((BaseExpression) baseExp).getBaseExpression()); this.setBaseExpression(outerBuilder); this.children.setElementAt(outerBuilder, 0);