/** * Remove a table from the statement. The table will * be dropped from the FROM part of the SQL statement. */ public void removeTable(DatabaseTable table) { getTables().remove(table); }
/** * Remove a table from the statement. The table will * be dropped from the FROM part of the SQL statement. */ public void removeTable(DatabaseTable table) { getTables().remove(table); }
/** * Remove a table from the statement. The table will * be dropped from the FROM part of the SQL statement. */ public void removeTable(DatabaseTable table) { getTables().removeElement(table); }
/** * If there is no where clause, alias the tables from the tables list directly. Assume there's * no ambiguity */ public void computeTablesFromTables() { Map<DatabaseTable, DatabaseTable> allTables = new Hashtable(); AsOfClause asOfClause = null; if (getBuilder().hasAsOfClause() && !getBuilder().getSession().getProject().hasGenericHistorySupport()) { asOfClause = getBuilder().getAsOfClause(); } for (int index = 0; index < getTables().size(); index++) { DatabaseTable next = getTables().get(index); // Aliases in allTables must now be decorated database tables. DatabaseTable alias = new DecoratedDatabaseTable("t" + (index), asOfClause); allTables.put(alias, next); } setTableAliases(allTables); }
/** * If there is no where clause, alias the tables from the tables list directly. Assume there's * no ambiguity */ public void computeTablesFromTables() { Map<DatabaseTable, DatabaseTable> allTables = new Hashtable(); AsOfClause asOfClause = null; if (getBuilder().hasAsOfClause() && !getBuilder().getSession().getProject().hasGenericHistorySupport()) { asOfClause = getBuilder().getAsOfClause(); } for (int index = 0; index < getTables().size(); index++) { DatabaseTable next = getTables().get(index); // Aliases in allTables must now be decorated database tables. DatabaseTable alias = new DecoratedDatabaseTable("t" + (index), asOfClause); allTables.put(alias, next); } setTableAliases(allTables); }
/** * If there is no where clause, alias the tables from the tables list directly. Assume there's * no ambiguity */ public void computeTablesFromTables() { Hashtable allTables = new Hashtable(); AsOfClause asOfClause = null; if (getBuilder().hasAsOfClause() && !getBuilder().getSession().getProject().hasGenericHistorySupport()) { asOfClause = getBuilder().getAsOfClause(); } for (int index = 0; index < getTables().size(); index++) { DatabaseTable next = (DatabaseTable)getTables().elementAt(index); // Aliases in allTables must now be decorated database tables. DatabaseTable alias = new DecoratedDatabaseTable("t" + (index), asOfClause); allTables.put(alias, next); } setTableAliases(allTables); }
updateAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().get(0))); updateAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getExecutionSession().getPlatform())); updateAllStatement.setPrimaryKeyFieldsForAutoJoin(primaryKeyFields);
updateAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().get(0))); updateAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getExecutionSession().getPlatform())); updateAllStatement.setPrimaryKeyFieldsForAutoJoin(primaryKeyFields);
updateAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().firstElement())); updateAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getSession().getPlatform())); updateAllStatement.setPrimaryKeyFieldsForAutoJoin(primaryKeyFields);
/** * INTERNAL: * Normalize an expression mapping all of the descriptor's tables to the view. * This is used to allow a descriptor to read from a view, but write to tables. * This is used in the multiple table and subclasses read so all of the descriptor's * possible tables must be mapped to the view. */ public void normalizeForView(AbstractSession theSession, ClassDescriptor theDescriptor, Map clonedExpressions) { ExpressionBuilder builder; // bug 3878553 - alias all view selects. setRequiresAliases(true); if (getWhereClause() != null) { builder = getWhereClause().getBuilder(); } else { builder = new ExpressionBuilder(); setBuilder(builder); } builder.setViewTable(getTables().get(0)); normalize(theSession, theDescriptor, clonedExpressions); }
/** * INTERNAL: * Normalize an expression mapping all of the descriptor's tables to the view. * This is used to allow a descriptor to read from a view, but write to tables. * This is used in the multiple table and subclasses read so all of the descriptor's * possible tables must be mapped to the view. */ public void normalizeForView(AbstractSession theSession, ClassDescriptor theDescriptor, Map clonedExpressions) { ExpressionBuilder builder; // bug 3878553 - alias all view selects. setRequiresAliases(true); if (getWhereClause() != null) { builder = getWhereClause().getBuilder(); } else { builder = new ExpressionBuilder(); setBuilder(builder); } builder.setViewTable(getTables().get(0)); normalize(theSession, theDescriptor, clonedExpressions); }
/** * INTERNAL: * Normalize an expression mapping all of the descriptor's tables to the view. * This is used to allow a descriptor to read from a view, but write to tables. * This is used in the multiple table and subclasses read so all of the descriptor's * possible tables must be mapped to the view. */ public void normalizeForView(AbstractSession theSession, ClassDescriptor theDescriptor, Map clonedExpressions) { ExpressionBuilder builder; // bug 3878553 - alias all view selects. setRequiresAliases(true); if (getWhereClause() != null) { builder = getWhereClause().getBuilder(); } else { builder = new ExpressionBuilder(); setBuilder(builder); } builder.setViewTable((DatabaseTable)getTables().firstElement()); normalize(theSession, theDescriptor, clonedExpressions); }
/** * 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)); } } } }
deleteAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().get(0))); deleteAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getExecutionSession().getPlatform())); } else {
deleteAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().get(0))); deleteAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getExecutionSession().getPlatform())); } else {
deleteAllStatement.setShouldExtractWhereClauseFromSelectCallForExist(!selectStatementForExist.requiresAliases() && table.equals(selectStatementForExist.getTables().firstElement())); deleteAllStatement.setTableAliasInSelectCallForExist(getAliasTableName(selectStatementForExist, table, getSession().getPlatform())); } else {
statement.setWhereClause(statement.getWhereClause().and(temporalExpression)); if (builder.hasAsOfClause()) { statement.getTables().set(0, getHistoryPolicy().getHistoricalTables().get(0));