コード例 #1
0
 /**
  * INTERNAL: The foreign key names and their primary keys are converted to DatabaseField and
  * stored.
  */
 protected void initializeForeignKeys(AbstractSession session) {
   HashMap newSourceToTargetQueryKeyNames = new HashMap(getSourceToTargetQueryKeyNames().size());
   Iterator iterator = getSourceToTargetQueryKeyNames().entrySet().iterator();
   while (iterator.hasNext()) {
     Map.Entry entry = (Map.Entry) iterator.next();
     DatabaseField field = getDescriptor().buildField((DatabaseField) entry.getKey());
     newSourceToTargetQueryKeyNames.put(field, entry.getValue());
   }
   this.sourceToTargetQueryKeyNames = newSourceToTargetQueryKeyNames;
 }
コード例 #2
0
  /**
   * INTERNAL: Used in case outer joins should be printed in FROM clause. Each of the additional
   * tables mapped to expressions that joins it.
   */
  public Map additionalExpressionCriteriaMap() {
    if (getDescriptor() == null) {
      return null;
    }

    HashMap tablesJoinExpressions = new HashMap();
    Vector tables = getDescriptor().getTables();
    // skip the main table - start with i=1
    int tablesSize = tables.size();
    if (shouldUseOuterJoin()) {
      for (int i = 1; i < tablesSize; i++) {
        DatabaseTable table = (DatabaseTable) tables.elementAt(i);
        Expression joinExpression =
            (Expression) getDescriptor().getQueryManager().getTablesJoinExpressions().get(table);
        joinExpression = getBaseExpression().twist(joinExpression, this);
        tablesJoinExpressions.put(table, joinExpression);
      }
    }
    if (isUsingOuterJoinForMultitableInheritance()) {
      List childrenTables = getDescriptor().getInheritancePolicy().getChildrenTables();
      tablesSize = childrenTables.size();
      for (int i = 0; i < tablesSize; i++) {
        DatabaseTable table = (DatabaseTable) childrenTables.get(i);
        Expression joinExpression =
            (Expression)
                getDescriptor()
                    .getInheritancePolicy()
                    .getChildrenTablesJoinExpressions()
                    .get(table);
        joinExpression = getBaseExpression().twist(joinExpression, this);
        tablesJoinExpressions.put(table, joinExpression);
      }
    }

    return tablesJoinExpressions;
  }