/** * ADVANCED: Return an expression representing a table in a data-level query. * This is used internally in EclipseLink, or to construct queries involving * fields and/or tables that are not mapped. * <p> Example: * <blockquote><pre> * builder.getTable("PROJ_EMP").getField("TYPE").equal("S"); * </pre></blockquote> */ public Expression getTable(String tableName) { DatabaseTable table = new DatabaseTable(tableName); return getTable(table); }
/** * ADVANCED: Return an expression representing a table in a data-level query. * This is used internally in EclipseLink, or to construct queries involving * fields and/or tables that are not mapped. * <p> Example: * <blockquote><pre> * builder.getTable("PROJ_EMP").getField("TYPE").equal("S"); * </pre></blockquote> */ public Expression getTable(String tableName) { DatabaseTable table = new DatabaseTable(tableName); return getTable(table); }
/** * ADVANCED: Return an expression representing a table in a data-level query. * This is used internally in TopLink, or to construct queries involving * fields and/or tables that are not mapped. * <p> Example: * <pre><blockquote> * builder.getTable("PROJ_EMP").getField("TYPE").equal("S"); * </blockquote></pre> */ public Expression getTable(String tableName) { DatabaseTable table = new DatabaseTable(tableName); return getTable(table); }
/** * INTERNAL: * Adds to the passed expression a single relation table field joined to source field. * Used to extend pessimistic locking clause in source query. */ public Expression joinRelationTableField(Expression expression, Expression baseExpression) { return baseExpression.getField(this.sourceKeyFields.get(0)).equal(baseExpression.getTable(relationTable).getField(this.sourceRelationKeyFields.get(0))).and(expression); }
/** * INTERNAL: * Adds to the passed expression a single relation table field joined to source field. * Used to extend pessimistic locking clause in source query. */ public Expression joinRelationTableField(Expression expression, Expression baseExpression) { return baseExpression.getField(this.sourceKeyFields.get(0)).equal(baseExpression.getTable(relationTable).getField(this.sourceRelationKeyFields.get(0))).and(expression); }
/** * INTERNAL: * Adds to the passed expression a single relation table field joined to source field. * Used to extend pessimistic locking clause in source query. */ public Expression joinRelationTableField(Expression expression, Expression baseExpression) { return baseExpression.getField(this.sourceKeyFields.get(0)).equal(baseExpression.getTable(relationTable).getField(this.sourceRelationKeyFields.get(0))).and(expression); }
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ @Override public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) { Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context, oldBase); return twistedBase.getTable(getTable()); }
/** * INTERNAL: * Creates expression for listOrderField * Precondition: listOrderField != null. */ public Expression getListOrderFieldExpression(Expression baseExpression) { if(shouldUseListOrderFieldTableExpression()) { baseExpression = baseExpression.getTable(this.listOrderField.getTable()); } return baseExpression.getField(this.listOrderField); }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ @Override public Expression rebuildOn(Expression newBase) { Expression newLocalBase = getBaseExpression().rebuildOn(newBase); return newLocalBase.getTable(getTable()); }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ @Override public Expression rebuildOn(Expression newBase) { Expression newLocalBase = getBaseExpression().rebuildOn(newBase); return newLocalBase.getTable(getTable()); }
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ public Expression twistedForBaseAndContext(Expression newBase, Expression context) { Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context); return twistedBase.getTable(getTable()); }
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ @Override public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) { Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context, oldBase); return twistedBase.getTable(getTable()); }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ public Expression rebuildOn(Expression newBase) { Expression newLocalBase = getBaseExpression().rebuildOn(newBase); return newLocalBase.getTable(getTable()); }
/** * {@inheritDoc} */ @Override public void visit(TableExpression expression) { String tableName = queryContext.literal(expression.getExpression(), LiteralType.STRING_LITERAL); tableName = ExpressionTools.unquote(tableName); queryExpression = queryContext.getBaseExpression().getTable(tableName); }
/** * {@inheritDoc} */ @Override public void visit(TableExpression expression) { String tableName = queryContext.literal(expression.getExpression(), LiteralType.STRING_LITERAL); tableName = ExpressionTools.unquote(tableName); queryExpression = queryContext.getBaseExpression().getTable(tableName); }
/** * {@inheritDoc} */ @Override Expression buildQueryExpression() { TableVariableDeclaration declaration = (TableVariableDeclaration) getBaseExpression(); String tableName = queryContext.literal(declaration.getTableExpression(), LiteralType.STRING_LITERAL); tableName = ExpressionTools.unquote(tableName); return queryContext.getBaseExpression().getTable(tableName); }
/** * {@inheritDoc} */ @Override Expression buildQueryExpression() { TableVariableDeclaration declaration = (TableVariableDeclaration) getBaseExpression(); String tableName = queryContext.literal(declaration.getTableExpression(), LiteralType.STRING_LITERAL); tableName = ExpressionTools.unquote(tableName); return queryContext.getBaseExpression().getTable(tableName); }
/** * INTERNAL: * Called when the selection query is being initialized to add any required additional fields to the * query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ if (baseExpression == null){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField((DatabaseField)keyField.clone()); ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addTable((DatabaseTable)keyField.getTable().clone()); } else { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getTable((DatabaseTable)keyField.getTable()).getField(keyField)); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the selection query is being initialized to add the fields for the map key to the query */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ Iterator i = getReferenceDescriptor().getAllFields().iterator(); while (i.hasNext()){ DatabaseField field = (DatabaseField)i.next(); if (selectionQuery.isObjectLevelReadQuery()){ if (baseExpression != null){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else { ((ObjectLevelReadQuery)selectionQuery).addAdditionalField((DatabaseField)field.clone()); } } else if (selectionQuery.isDataReadQuery()){ if (baseExpression == null){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField((DatabaseField)field.clone()); if (!((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).getTables().contains(field.getTable())){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addTable((DatabaseTable)field.getTable().clone()); } } else { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getTable(field.getTable()).getField(field)); } } } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the selection query is being initialized to add the fields for the map key to the query */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ if (selectionQuery.isObjectLevelReadQuery()){ if (baseExpression == null){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField((DatabaseField)getField().clone()); } else { ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(getField())); } } else if (selectionQuery.isDataReadQuery()){ if (baseExpression == null){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField((DatabaseField)getField().clone()); ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addTable((DatabaseTable)getField().getTable().clone()); } else { ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(baseExpression.getTable(getField().getTable()).getField(getField())); } } }