/** * ADVANCED: Return the SQL string of the query. This can be used for SQL * queries. This can also be used for normal queries if they have been * prepared, (i.e. query.prepareCall()). * * @see #prepareCall(org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.Record) prepareCall(Session, Record) */ public String getSQLString() { Call call = getDatasourceCall(); if (call == null) { return null; } if (!(call instanceof SQLCall)) { return null; } return ((SQLCall) call).getSQLString(); }
/** * ADVANCED: Return the SQL string of the query. This can be used for SQL * queries. This can also be used for normal queries if they have been * prepared, (i.e. query.prepareCall()). * * @see #prepareCall(org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.Record) prepareCall(Session, Record) */ public String getSQLString() { Call call = getDatasourceCall(); if (call == null) { return null; } if (!(call instanceof SQLCall)) { return null; } return ((SQLCall) call).getSQLString(); }
/** * ADVANCED: * Return the SQL string of the query. * This can be used for SQL queries. * This can also be used for normal queries if they have been prepared, (i.e. query.prepareCall()). * @see #prepareCall(Session, Record) */ public String getSQLString() { Call call = getDatasourceCall(); if (call == null) { return null; } if (!(call instanceof SQLCall)) { return null; } return ((SQLCall)call).getSQLString(); }
/** * ADVANCED: * Return the SQL strings of the query. Used for queries with multiple calls * This can be used for SQL queries. * This can also be used for normal queries if they have been prepared, (i.e. query.prepareCall()). * @see #prepareCall(Session, Record) */ public List getSQLStrings() { List calls = getDatasourceCalls(); if ((calls == null) || calls.isEmpty()) { return null; } Vector returnSQL = new Vector(calls.size()); Iterator iterator = calls.iterator(); while (iterator.hasNext()) { Call call = (Call)iterator.next(); if (!(call instanceof SQLCall)) { return null; } returnSQL.addElement(((SQLCall)call).getSQLString()); } return returnSQL; }
/** * ADVANCED: Return the SQL strings of the query. Used for queries with * multiple calls This can be used for SQL queries. This can also be used * for normal queries if they have been prepared, (i.e. * query.prepareCall()). * * @see #prepareCall(org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.Record) prepareCall(Session, Record) */ public List getSQLStrings() { List calls = getDatasourceCalls(); if ((calls == null) || calls.isEmpty()) { return null; } Vector returnSQL = new Vector(calls.size()); Iterator iterator = calls.iterator(); while (iterator.hasNext()) { Call call = (Call) iterator.next(); if (!(call instanceof SQLCall)) { return null; } returnSQL.addElement(((SQLCall) call).getSQLString()); } return returnSQL; }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected boolean writeWhere(Writer writer, SQLCall selectCall, SQLCall call) throws IOException { String selectStr = selectCallForExist.getSQLString(); int index = selectStr.toUpperCase().indexOf(" WHERE "); if(index < 0) { // no where clause - nothing to do return false; } // print the where clause String str = selectStr.substring(index); writer.write(str); // add parameters call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); return true; } }
protected void writeSelect(Writer writer, SQLCall selectCall, String tableAliasInSelectCall, SQLCall call, DatasourcePlatform platform) throws IOException { String str = selectCall.getSQLString(); writer.write(str); boolean hasWhereClause = str.toUpperCase().indexOf(" WHERE ") >= 0; // Auto join // Example: AND t0.EMP_ID = EMP_ID Iterator it = getPrimaryKeyFieldsForAutoJoin().iterator(); while(it.hasNext()) { if(!hasWhereClause) { // there is no where clause - should print WHERE writer.write(" WHERE "); hasWhereClause = true; } else { writer.write(" AND "); } String fieldName = ((DatabaseField)it.next()).getNameDelimited(platform); if(tableAliasInSelectCall != null) { writer.write(tableAliasInSelectCall); writer.write('.'); } writer.write(fieldName); writer.write(" = "); writer.write(table.getQualifiedNameDelimited(platform)); writer.write('.'); writer.write(fieldName); } call.getParameters().addAll(selectCall.getParameters()); call.getParameterTypes().addAll(selectCall.getParameterTypes()); }
/** * INTERNAL: * Uses the returning clause on Postgres. */ public DatabaseCall buildCallWithReturning(SQLCall sqlCall, Vector returnFields) { SQLCall call = new SQLCall(); call.setParameters(sqlCall.getParameters()); call.setParameterTypes(sqlCall.getParameterTypes()); call.returnOneRow(); Writer writer = new CharArrayWriter(sqlCall.getSQLString().length() + 32); try { writer.write(sqlCall.getSQLString()); writer.write(" RETURNING "); for (int i = 0; i < returnFields.size(); i++) { DatabaseField field = (DatabaseField)returnFields.elementAt(i); writer.write(field.getNameDelimited(this)); if ((i + 1) < returnFields.size()) { writer.write(", "); } } call.setQueryString(writer.toString()); } catch (IOException exception) { throw ValidationException.fileError(exception); } return call; }
/** * INTERNAL: * Uses the returning clause on Postgres. */ public DatabaseCall buildCallWithReturning(SQLCall sqlCall, Vector returnFields) { SQLCall call = new SQLCall(); call.setParameters(sqlCall.getParameters()); call.setParameterTypes(sqlCall.getParameterTypes()); call.returnOneRow(); Writer writer = new CharArrayWriter(sqlCall.getSQLString().length() + 32); try { writer.write(sqlCall.getSQLString()); writer.write(" RETURNING "); for (int i = 0; i < returnFields.size(); i++) { DatabaseField field = (DatabaseField)returnFields.elementAt(i); writer.write(field.getNameDelimited(this)); if ((i + 1) < returnFields.size()) { writer.write(", "); } } call.setQueryString(writer.toString()); } catch (IOException exception) { throw ValidationException.fileError(exception); } return call; }
/** * ADVANCED: This can be used to access a queries translated SQL if they * have been prepared, (i.e. query.prepareCall()). This method can be used * for queries with multiple calls. * * @see #prepareCall(org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.Record) prepareCall(Session, Record) */ public List getTranslatedSQLStrings(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); CallQueryMechanism queryMechanism = (CallQueryMechanism) getQueryMechanism(); if ((queryMechanism.getCalls() == null) || queryMechanism.getCalls().isEmpty()) { return null; } Vector calls = new Vector(queryMechanism.getCalls().size()); Iterator iterator = queryMechanism.getCalls().iterator(); while (iterator.hasNext()) { SQLCall call = (SQLCall) iterator.next(); call = (SQLCall) call.clone(); call.setUsesBinding(false); call.translate((AbstractRecord) translationRow, queryMechanism.getModifyRow(), (AbstractSession) session); calls.add(call.getSQLString()); } return calls; }
/** * ADVANCED: This can be used to access a queries translated SQL if they * have been prepared, (i.e. query.prepareCall()). This method can be used * for queries with multiple calls. * * @see #prepareCall(org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.Record) prepareCall(Session, Record) */ public List getTranslatedSQLStrings(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); CallQueryMechanism queryMechanism = (CallQueryMechanism) getQueryMechanism(); if ((queryMechanism.getCalls() == null) || queryMechanism.getCalls().isEmpty()) { return null; } Vector calls = new Vector(queryMechanism.getCalls().size()); Iterator iterator = queryMechanism.getCalls().iterator(); while (iterator.hasNext()) { SQLCall call = (SQLCall) iterator.next(); call = (SQLCall) call.clone(); call.setUsesBinding(false); call.translate((AbstractRecord) translationRow, queryMechanism.getModifyRow(), (AbstractSession) session); calls.add(call.getSQLString()); } return calls; }
/** * ADVANCED: * This can be used to access a queries translated SQL if they have been prepared, (i.e. query.prepareCall()). * This method can be used for queries with multiple calls. * @see #prepareCall(Session, Record) */ public List getTranslatedSQLStrings(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); CallQueryMechanism queryMechanism = (CallQueryMechanism)getQueryMechanism(); if ((queryMechanism.getCalls() == null) || queryMechanism.getCalls().isEmpty()) { return null; } Vector calls = new Vector(queryMechanism.getCalls().size()); Iterator iterator = queryMechanism.getCalls().iterator(); while (iterator.hasNext()) { SQLCall call = (SQLCall)iterator.next(); call = (SQLCall)call.clone(); call.setUsesBinding(false); call.translate((AbstractRecord)translationRow, queryMechanism.getModifyRow(), (AbstractSession)session); calls.add(call.getSQLString()); } return calls; }
/** * ADVANCED: * This can be used to access a queries translated SQL if they have been prepared, (i.e. query.prepareCall()). * The Record argument is one of (Record, XMLRecord) that contains the query arguments. * @see #prepareCall(org.eclipse.persistence.sessions.Session, Record) */ public String getTranslatedSQLString(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); //CR#2859559 fix to use Session and Record interfaces not impl classes. CallQueryMechanism queryMechanism = (CallQueryMechanism)getQueryMechanism(); if (queryMechanism.getCall() == null) { return null; } SQLCall call = (SQLCall)queryMechanism.getCall().clone(); call.setUsesBinding(false); call.translate((AbstractRecord)translationRow, queryMechanism.getModifyRow(), (AbstractSession)session); return call.getSQLString(); }
/** * ADVANCED: This can be used to access a queries translated SQL if they * have been prepared, (i.e. query.prepareCall()). The Record argument is * one of (Record, XMLRecord) that contains the query arguments. * * @see #prepareCall(org.eclipse.persistence.sessions.Session, Record) */ public String getTranslatedSQLString(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); // CR#2859559 fix to use Session and Record interfaces not impl classes. CallQueryMechanism queryMechanism = (CallQueryMechanism) getQueryMechanism(); if (queryMechanism.getCall() == null) { return null; } SQLCall call = (SQLCall) queryMechanism.getCall().clone(); call.setUsesBinding(false); call.translate((AbstractRecord) translationRow, queryMechanism.getModifyRow(), (AbstractSession) session); return call.getSQLString(); }
/** * ADVANCED: This can be used to access a queries translated SQL if they * have been prepared, (i.e. query.prepareCall()). The Record argument is * one of (Record, XMLRecord) that contains the query arguments. * * @see #prepareCall(org.eclipse.persistence.sessions.Session, Record) */ public String getTranslatedSQLString(org.eclipse.persistence.sessions.Session session, Record translationRow) { prepareCall(session, translationRow); // CR#2859559 fix to use Session and Record interfaces not impl classes. CallQueryMechanism queryMechanism = (CallQueryMechanism) getQueryMechanism(); if (queryMechanism.getCall() == null) { return null; } SQLCall call = (SQLCall) queryMechanism.getCall().clone(); call.setUsesBinding(false); call.translate((AbstractRecord) translationRow, queryMechanism.getModifyRow(), (AbstractSession) session); return call.getSQLString(); }