/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendModify(Writer writer, DatabaseField modifyField) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(modifyField); getParameterTypes().addElement(MODIFY); }
/** * INTERNAL: * Returns value for INOUT parameter. Called by translate and translateSQLString methods. */ protected Object getValueForInOutParameter(Object parameter, AbstractRecord translationRow, AbstractRecord modifyRow, AbstractSession session) { // parameter ts an array of two Objects: inParameter and outParameter Object inParameter = ((Object[])parameter)[0]; Object inValue = getValueForInParameter(inParameter, translationRow, modifyRow, session, true); Object outParameter = ((Object[])parameter)[1]; return createInOutParameter(inValue, outParameter, session); }
if (getQueryString().indexOf("#") == -1) { if (this.getQuery().shouldBindAllParameters() && getQueryString().indexOf("?") == -1){ return; translatePureSQLCustomQuery(); return; String queryString = getQueryString(); Writer writer = new CharArrayWriter(queryString.length() + 50); try { if (poundIndex != -1) { int wordEndIndex = poundIndex + 1; while ((wordEndIndex < queryString.length()) && (whitespace().indexOf(queryString.charAt(wordEndIndex)) == -1)) { wordEndIndex = wordEndIndex + 1; DatabaseField field = createField(fieldName); appendInOut(writer, field); } else { String fieldName = queryString.substring(poundIndex + 3, wordEndIndex); DatabaseField field = createField(fieldName); appendOut(writer, field); DatabaseField field = createField(fieldName); appendModify(writer, field); DatabaseField field = createField(fieldName); appendIn(writer, field);
if (getQueryString().indexOf(argumentMarker()) == -1) { return; if (getParameters().isEmpty()) { String queryString = getQueryString(); Writer writer = new CharArrayWriter(queryString.length() + 50); try { Vector parameterFields = getParameters(); setParameters(null); while (lastIndex != -1) { int tokenIndex = queryString.indexOf(argumentMarker(), lastIndex); String token; if (tokenIndex == -1) { Integer parameterType = (Integer)getParameterTypes().elementAt(parameterIndex); if (parameterType == MODIFY) { DatabaseField field = (DatabaseField)parameterFields.elementAt(parameterIndex); Object value = modifyRow.get(field); appendParameter(writer, value, session); } else if (parameterType == CUSTOM_MODIFY) { DatabaseField field = (DatabaseField)parameterFields.elementAt(parameterIndex); appendParameter(writer, value, session); } else if (parameterType == TRANSLATION) { Object parameter = parameterFields.elementAt(parameterIndex); appendParameter(writer, value, session);
String queryString = getQueryString(); int parameterIndex = 1; // this is the parameter index Writer writer = new CharArrayWriter(queryString.length() + 50); if (markIndex != -1) { // found the question mark now find the named token int wordEndIndex = markIndex + 1; while ((wordEndIndex < queryString.length()) && (whitespace().indexOf(queryString.charAt(wordEndIndex)) == -1)) { wordEndIndex = wordEndIndex + 1; DatabaseField field = createField(fieldName); appendIn(writer, field); lastIndex = wordEndIndex; }else{ DatabaseField field = createField(String.valueOf(parameterIndex)); parameterIndex++; appendIn(writer, field); throw ValidationException.fileError(exception); setQueryString(writer.toString());
/** * Execute the call. It is assumed the call has been fully prepared. * @exception DatabaseException - an error has occurred on the database. */ protected Object executeCall(DatasourceCall databaseCall) throws DatabaseException { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = getSession().getExecutionSession(getQuery()); DatasourceCall clonedCall = (DatasourceCall)databaseCall.clone(); clonedCall.setQuery(getQuery()); clonedCall.translate(getTranslationRow(), getModifyRow(), sessionToUse); return sessionToUse.executeCall(clonedCall, getTranslationRow(), getQuery()); }
/** * Update the foreign key fields when resolving a bi-directonal reference in a UOW. * This is rare to occur for non-relational, however if it does each of the calls must be re-executed. */ protected void updateForeignKeyFieldShallow(WriteObjectQuery writeQuery) { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = getSession().getExecutionSession(getQuery()); // yes - this is a bit ugly... Vector calls = ((DatasourceCallQueryMechanism)this.getDescriptor().getQueryManager().getUpdateQuery().getQueryMechanism()).getCalls(); for (Enumeration stream = calls.elements(); stream.hasMoreElements();) { DatasourceCall call = (DatasourceCall)((DatasourceCall)stream.nextElement()).clone(); call.setQuery(writeQuery); sessionToUse.executeCall(call, this.getTranslationRow(), writeQuery); } } }
/** * 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 (DatabaseRow, XMLRecord) that contains the query arguments. * @see #prepareCall(oracle.toplink.essentials.sessions.Session, Record) */ public String getTranslatedSQLString(oracle.toplink.essentials.sessions.Session session, Record 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.translate((AbstractRecord)translationRow, queryMechanism.getModifyRow(), (AbstractSession)session); return call.getSQLString(); }
/** * Return the appropriate mechanism, * with the call added as necessary. */ public DatabaseQueryMechanism buildQueryMechanism(DatabaseQuery query, DatabaseQueryMechanism mechanism) { if (mechanism.isCallQueryMechanism() && (mechanism instanceof DatasourceCallQueryMechanism)) { // Must also add the call singleton... DatasourceCallQueryMechanism callMechanism = ((DatasourceCallQueryMechanism)mechanism); if (!callMechanism.hasMultipleCalls()) { callMechanism.addCall(callMechanism.getCall()); callMechanism.setCall(null); } callMechanism.addCall(this); return mechanism; } else { return buildNewQueryMechanism(query); } }
/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendIn(Writer writer, DatabaseField field) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(field); getParameterTypes().addElement(IN); }
/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendTranslation(Writer writer, DatabaseField modifyField) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(modifyField); getParameterTypes().addElement(TRANSLATION); }
/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendLiteral(Writer writer, Object literal) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(literal); getParameterTypes().addElement(LITERAL); }
/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendOut(Writer writer, DatabaseField outField) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(outField); getParameterTypes().addElement(OUT); }
/** * INTERNAL: * All values are printed as ? to allow for parameter binding or translation during the execute of the call. */ public void appendInOut(Writer writer, DatabaseField inoutField) { try { writer.write(argumentMarker()); } catch (IOException exception) { throw ValidationException.fileError(exception); } Object[] inOut = { inoutField, inoutField }; getParameters().addElement(inOut); getParameterTypes().addElement(INOUT); }