org.eclipse.persistence.internal.expressions.QueryKeyExpression.isAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(16.0k)|赞(0)|评价(0)|浏览(56)

本文整理了Java中org.eclipse.persistence.internal.expressions.QueryKeyExpression.isAttribute方法的一些代码示例,展示了QueryKeyExpression.isAttribute的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryKeyExpression.isAttribute方法的具体详情如下:
包路径:org.eclipse.persistence.internal.expressions.QueryKeyExpression
类名称:QueryKeyExpression
方法名:isAttribute

QueryKeyExpression.isAttribute介绍

[英]INTERNAL: Return if the expression is for a direct mapped attribute.
[中]内部:如果表达式用于直接映射属性,则返回。

代码示例

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Return all the fields
 */
public Vector getFields() {
  if (isAttribute()) {
    Vector result = new Vector(1);
    DatabaseField field = getField();
    if (field != null) {
      result.addElement(field);
    }
    return result;
  } else {
    Vector result = new Vector();
    result.addAll(super.getFields());
    if (mapping.isCollectionMapping()){
      List<DatabaseField> fields = mapping.getContainerPolicy().getAllFieldsForMapKey((CollectionMapping)mapping);
      if (fields != null){
        result.addAll(fields);
      }
    }
    return result;
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 */
@Override
public List<DatabaseField> getSelectionFields(ReadQuery query) {
  if (isAttribute()) {
    List<DatabaseField> result = new ArrayList<DatabaseField>(1);
    DatabaseField field = getField();
    if (field != null) {
      result.add(field);
    }
    return result;
  } else {
    List<DatabaseField> result = new ArrayList<DatabaseField>();
    result.addAll(super.getSelectionFields(query));
    if ((this.mapping != null) && this.mapping.isCollectionMapping()){
      List<DatabaseField> fields = this.mapping.getContainerPolicy().getAdditionalFieldsForJoin((CollectionMapping)this.mapping);
      if (fields != null){
        result.addAll(fields);
      }
    }
    return result;
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 */
@Override
public List<DatabaseField> getSelectionFields(ReadQuery query) {
  if (isAttribute()) {
    List<DatabaseField> result = new ArrayList<DatabaseField>(1);
    DatabaseField field = getField();
    if (field != null) {
      result.add(field);
    }
    return result;
  } else {
    List<DatabaseField> result = new ArrayList<DatabaseField>();
    result.addAll(super.getSelectionFields(query));
    if ((this.mapping != null) && this.mapping.isCollectionMapping()){
      List<DatabaseField> fields = this.mapping.getContainerPolicy().getAdditionalFieldsForJoin((CollectionMapping)this.mapping);
      if (fields != null){
        result.addAll(fields);
      }
    }
    return result;
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Return all the fields
 */
@Override
public Vector getFields() {
  if (isAttribute()) {
    Vector result = new Vector(1);
    DatabaseField field = getField();
    if (field != null) {
      result.addElement(field);
    }
    return result;
  } else {
    Vector result = new Vector();
    result.addAll(super.getFields());
    if ((this.mapping != null) && this.mapping.isCollectionMapping()){
      List<DatabaseField> fields = this.mapping.getContainerPolicy().getAdditionalFieldsForJoin((CollectionMapping)this.mapping);
      if (fields != null){
        result.addAll(fields);
      }
    }
    return result;
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Return all the fields
 */
@Override
public Vector getFields() {
  if (isAttribute()) {
    Vector result = new Vector(1);
    DatabaseField field = getField();
    if (field != null) {
      result.addElement(field);
    }
    return result;
  } else {
    Vector result = new Vector();
    result.addAll(super.getFields());
    if ((this.mapping != null) && this.mapping.isCollectionMapping()){
      List<DatabaseField> fields = this.mapping.getContainerPolicy().getAdditionalFieldsForJoin((CollectionMapping)this.mapping);
      if (fields != null){
        result.addAll(fields);
      }
    }
    return result;
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 */
@Override
public DatabaseField getField() {
  if (!isAttribute()) {
    return null;
  }
  QueryKey key = getQueryKeyOrNull();
  if ((key != null) && key.isDirectQueryKey()) {
    return ((DirectQueryKey)key).getField();
  }
  DatabaseMapping mapping = getMapping();
  if ((mapping == null) || mapping.getFields().isEmpty()) {
    return null;
  }
  return mapping.getFields().get(0);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 */
public DatabaseField getField() {
  if (!isAttribute()) {
    return null;
  }
  return getContainingDescriptor().getObjectBuilder().getFieldForQueryKeyName(getName());
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 */
@Override
public DatabaseField getField() {
  if (!isAttribute()) {
    return null;
  }
  QueryKey key = getQueryKeyOrNull();
  if ((key != null) && key.isDirectQueryKey()) {
    return ((DirectQueryKey)key).getField();
  }
  DatabaseMapping mapping = getMapping();
  if ((mapping == null) || mapping.getFields().isEmpty()) {
    return null;
  }
  return mapping.getFields().get(0);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * 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());
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * 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());
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * 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());
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * 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;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * 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;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Print SQL onto the stream, using the ExpressionPrinter for context
 */
@Override
public void printSQL(ExpressionSQLPrinter printer) {
  if (isAttribute()) {
    printer.printField(getAliasedField());
  }
  // If the mapping is a direct collection then this falls into a gray area.
  // It must be treated as an attribute at this moment for it has a direct field.
  // However it is not an attribute in the sense that it also represents a foreign
  // reference and a mapping criteria has been added.
  // For bug 2900974 these are now handled as non-attributes during normalize but
  // as attributes when printing SQL.
  //
  if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) {
    DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping();
    // The aliased table comes for free as it was a required part of the join criteria.
    TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable());
    DatabaseTable aliasedTable = table.aliasForTable(table.getTable());
    DatabaseField aliasedField = directCollectionMapping.getDirectField().clone();
    aliasedField.setTable(aliasedTable);
    printer.printField(aliasedField);
  }
  if ((getMapping() != null) && getMapping().isNestedTableMapping()) {
    DatabaseTable tableAlias = aliasForTable(new NestedTable(this));
    printer.printString(tableAlias.getName());
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * 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;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Print SQL onto the stream, using the ExpressionPrinter for context
 */
public void printSQL(ExpressionSQLPrinter printer) {
  if (isAttribute()) {
    printer.printField(getAliasedField());
  }
  // If the mapping is a direct collection then this falls into a gray area.
  // It must be treated as an attribute at this moment for it has a direct field.
  // However it is not an attribute in the sense that it also represents a foreign
  // reference and a mapping criteria has been added.
  // For bug 2900974 these are now handled as non-attributes during normalize but
  // as attributes when printing SQL.
  //
  if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) {
    DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping();
    // The aliased table comes for free as it was a required part of the join criteria.
    TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable());
    DatabaseTable aliasedTable = table.aliasForTable(table.getTable());
    DatabaseField aliasedField = (DatabaseField)directCollectionMapping.getDirectField().clone();
    aliasedField.setTable(aliasedTable);
    printer.printField(aliasedField);
  }
  if ((getMapping() != null) && getMapping().isNestedTableMapping()) {
    DatabaseTable tableAlias = aliasForTable(new NestedTable(this));
    printer.printString(tableAlias.getName());
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Print SQL onto the stream, using the ExpressionPrinter for context
 */
@Override
public void printSQL(ExpressionSQLPrinter printer) {
  if (isAttribute()) {
    printer.printField(getAliasedField());
  }
  // If the mapping is a direct collection then this falls into a gray area.
  // It must be treated as an attribute at this moment for it has a direct field.
  // However it is not an attribute in the sense that it also represents a foreign
  // reference and a mapping criteria has been added.
  // For bug 2900974 these are now handled as non-attributes during normalize but
  // as attributes when printing SQL.
  //
  if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) {
    DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping();
    // The aliased table comes for free as it was a required part of the join criteria.
    TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable());
    DatabaseTable aliasedTable = table.aliasForTable(table.getTable());
    DatabaseField aliasedField = directCollectionMapping.getDirectField().clone();
    aliasedField.setTable(aliasedTable);
    printer.printField(aliasedField);
  }
  if ((getMapping() != null) && getMapping().isNestedTableMapping()) {
    DatabaseTable tableAlias = aliasForTable(new NestedTable(this));
    printer.printString(tableAlias.getName());
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Find the alias for a given table
 */
@Override
public DatabaseTable aliasForTable(DatabaseTable table) {
  DatabaseMapping mapping = getMapping();
  if (isAttribute() || ((mapping != null) && (mapping.isAggregateObjectMapping() || mapping.isTransformationMapping()))) {
    return ((DataExpression)this.baseExpression).aliasForTable(table);
  }
  //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table
  if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) {
    DatabaseTable alias = this.baseExpression.aliasForTable(mapping.getDescriptor().getTables().firstElement());
    alias.setName(alias.getName() + "." + mapping.getField().getName());
    return alias;
  }
  // For direct-collection mappings the alias is store on the table expression.
  if ((mapping != null) && (mapping.isDirectCollectionMapping())) {
    if (tableAliases != null){
      DatabaseTable aliasedTable = tableAliases.keyAtValue(table);
      if (aliasedTable != null){
        return aliasedTable;
      }
    }
    return getTable(table).aliasForTable(table);
  }
  return super.aliasForTable(table);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Find the alias for a given table
 */
@Override
public DatabaseTable aliasForTable(DatabaseTable table) {
  DatabaseMapping mapping = getMapping();
  if (isAttribute() || ((mapping != null) && (mapping.isAggregateObjectMapping() || mapping.isTransformationMapping()))) {
    return ((DataExpression)this.baseExpression).aliasForTable(table);
  }
  //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table
  if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) {
    DatabaseTable alias = this.baseExpression.aliasForTable(mapping.getDescriptor().getTables().firstElement());
    alias.setName(alias.getName() + "." + mapping.getField().getName());
    return alias;
  }
  
  // For direct-collection mappings the alias is store on the table expression.
  if ((mapping != null) && (mapping.isDirectCollectionMapping())) {
    if (tableAliases != null){
      DatabaseTable aliasedTable = tableAliases.keyAtValue(table);
      if (aliasedTable != null){
        return aliasedTable;
      }
    }
    return getTable(table).aliasForTable(table);
  }
  return super.aliasForTable(table);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Find the alias for a given table
 */
public DatabaseTable aliasForTable(DatabaseTable table) {
  DatabaseMapping mapping = getMapping();
  if (isAttribute() || ((mapping != null) && (mapping.isAggregateObjectMapping() || mapping.isTransformationMapping()))) {
    return ((DataExpression)getBaseExpression()).aliasForTable(table);
  }
  //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table
  if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) {
    DatabaseTable alias = getBaseExpression().aliasForTable(mapping.getDescriptor().getTables().firstElement());
    alias.setName(alias.getName() + "." + mapping.getField().getName());
    return alias;
  }
  
  // For direct-collection mappings the alias is store on the table expression.
  if ((mapping != null) && (mapping.isDirectCollectionMapping())) {
    if (tableAliases != null){
      DatabaseTable aliasedTable = tableAliases.keyAtValue(table);
      if (aliasedTable != null){
        return aliasedTable;
      }
    }
    return getTable(table).aliasForTable(table);
  }
  return super.aliasForTable(table);
}

相关文章

微信公众号

最新文章

更多

QueryKeyExpression类方法