/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * INTERNAL: * Normalize the expression into a printable structure. */ public Expression normalize(ExpressionNormalizer normalizer) { Expression expression = super.normalize(normalizer); // to support custom types, print expressions derived from field expressions, table expressions and direct query keys with their aliases if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || getBaseExpression().isTableExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBuilder().getStatement().setRequiresAliases(true); } return expression; }
/** * INTERNAL: * Normalize the expression into a printable structure. */ public Expression normalize(ExpressionNormalizer normalizer) { if (this.hasBeenNormalized) { return this; } Expression expression = super.normalize(normalizer); // to support custom types, print expressions derived from field expressions, table expressions and direct query keys with their aliases if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || getBaseExpression().isTableExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBuilder().getStatement().setRequiresAliases(true); } return expression; }
/** * INTERNAL: * Normalize the expression into a printable structure. */ public Expression normalize(ExpressionNormalizer normalizer) { if (this.hasBeenNormalized) { return this; } Expression expression = super.normalize(normalizer); // to support custom types, print expressions derived from field expressions, table expressions and direct query keys with their aliases if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || getBaseExpression().isTableExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBuilder().getStatement().setRequiresAliases(true); } return 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" */ public Expression twistedForBaseAndContext(Expression newBase, Expression context) { Expression twistedBase = getBaseExpression().twistedForBaseAndContext(newBase, context); return twistedBase.getField(getField()); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { getBaseExpression().printJava(printer); printer.printString(".getField(\"" + getField().getQualifiedName() + "\")"); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { getBaseExpression().printJava(printer); printer.printString(".getField(\"" + getField().getQualifiedName() + "\")"); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { getBaseExpression().printJava(printer); printer.printString(".getField(\"" + getField().getQualifiedName() + "\")"); }
/** * Do any required validation for this node. Throw an exception if it's incorrect. */ public void validateNode() { DataExpression base = (DataExpression)getBaseExpression(); if (getField().getTable().hasName()) { List<DatabaseTable> tables = base.getOwnedTables(); if ((tables != null) && (!tables.contains((getField().getTable())))) { throw QueryException.invalidTableForFieldInExpression(getField()); } } }
/** * 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) { FieldExpression expression = new FieldExpression(getField(), getBaseExpression().rebuildOn(newBase)); expression.setSelectIfOrderedBy(selectIfOrderedBy()); return expression; }
/** * Do any required validation for this node. Throw an exception if it's incorrect. */ public void validateNode() { DataExpression base = (DataExpression)getBaseExpression(); if (getField().getTable().hasName()) { List<DatabaseTable> tables = base.getOwnedTables(); if ((tables != null) && (!tables.contains((getField().getTable())))) { throw QueryException.invalidTableForFieldInExpression(getField()); } } }
/** * Do any required validation for this node. Throw an exception if it's incorrect. */ public void validateNode() { DataExpression base = (DataExpression)getBaseExpression(); if (getField().getTable().hasName()) { Vector tables = base.getOwnedTables(); if ((tables != null) && (!tables.contains((getField().getTable())))) { throw QueryException.invalidTableForFieldInExpression(getField()); } } }
/** * INTERNAL: * Return the value for in memory comparison. * This is only valid for valueable expressions. */ public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { // Joins not supported. if (!getBaseExpression().isExpressionBuilder()) { throw QueryException.cannotConformExpression(); } // For bug 2780817 get the mapping directly from the object. In EJB 2.0 // inheritance, each child must override mappings defined in an abstract // class with its own. DatabaseMapping mapping = session.getDescriptor(object.getClass()).getObjectBuilder().getMappingForField(getField()); if (mapping == null) { throw QueryException.cannotConformExpression(); } return mapping.valueFromObject(object, getField(), session); }
/** * INTERNAL: * Return the value for in memory comparison. * This is only valid for valueable expressions. */ public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { // Joins not supported. if (!getBaseExpression().isExpressionBuilder()) { throw QueryException.cannotConformExpression(); } // For bug 2780817 get the mapping directly from the object. In EJB 2.0 // inheritance, each child must override mappings defined in an abstract // class with its own. DatabaseMapping mapping = session.getDescriptor(object.getClass()).getObjectBuilder().getMappingForField(getField()); if (mapping == null) { throw QueryException.cannotConformExpression(); } return mapping.valueFromObject(object, getField(), session); }
/** * INTERNAL: * Return the value for in memory comparison. * This is only valid for valueable expressions. */ public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { // Joins not supported. if (!getBaseExpression().isExpressionBuilder()) { throw QueryException.cannotConformExpression(); } // For bug 2780817 get the mapping directly from the object. In EJB 2.0 // inheritance, each child must override mappings defined in an abstract // class with its own. DatabaseMapping mapping = session.getDescriptor(object.getClass()).getObjectBuilder().getMappingForField(getField()); if (mapping == null) { throw QueryException.cannotConformExpression(); } return mapping.valueFromObject(object, getField(), session); }
/** * Return the alias for our table */ private DatabaseTable getAliasedTable() { DataExpression base = (DataExpression)getBaseExpression(); DatabaseField field = getField(); if (!field.hasTableName()) { if (base.getDescriptor() != null){ field = base.getDescriptor().buildField(field); } } DatabaseTable alias = base.aliasForTable(field.getTable()); if (alias == null) { return field.getTable(); } else { return alias; } }
/** * Return the alias for our table */ private DatabaseTable getAliasedTable() { DataExpression base = (DataExpression)getBaseExpression(); DatabaseField field = getField(); if (!field.hasTableName()) { if (base.getDescriptor() != null){ field = base.getDescriptor().buildField(field); } } DatabaseTable alias = base.aliasForTable(field.getTable()); if (alias == null) { return field.getTable(); } else { return alias; } }
/** * Return the alias for our table */ private DatabaseTable getAliasedTable() { DataExpression base = (DataExpression)getBaseExpression(); DatabaseField field = getField(); if (!field.hasTableName()) { if (base.getDescriptor() != null){ field = base.getDescriptor().buildField(field); } } DatabaseTable alias = base.aliasForTable(field.getTable()); if (alias == null) { return field.getTable(); } else { return alias; } }