/** * Return the ResultSetMappingQuery for this stored procedure query. * NOTE: Methods assumes associated database query is a ResultSetMappingQuery. */ protected ResultSetMappingQuery getResultSetMappingQuery() { if (executeCall != null) { return (ResultSetMappingQuery) executeCall.getQuery(); } else { return (ResultSetMappingQuery) getDatabaseQuery(); } }
/** * INTERNAL: * Unfortunately can't avoid referencing query and descriptor: * the call should be performed after the translateCustomSQL (in SQLCall) * in the middle of prepare method (no parameter available earlier). * */ protected DatabaseField getFieldWithTypeFromDescriptor(DatabaseField outField) { if (getQuery().getDescriptor() != null) { return getQuery().getDescriptor().getTypedField(outField); } else { return null; } }
/** * INTERNAL: * Unfortunately can't avoid referencing query and descriptor: * the call should be performed after the translateCustomSQL (in SQLCall) * in the middle of prepare method (no parameter available earlier). * */ protected DatabaseField getFieldWithTypeFromDescriptor(DatabaseField outField) { if (getQuery().getDescriptor() != null) { return getQuery().getDescriptor().getTypedField(outField); } else { return null; } }
/** * INTERNAL: * Unfortunately can't avoid referencing query and descriptor: * the call should be performed after the translateCustomSQL (in SQLCall) * in the middle of prepare method (no parameter available earlier). * */ protected DatabaseField getFieldWithTypeFromDescriptor(DatabaseField outField) { if (getQuery().getDescriptor() != null) { return getQuery().getDescriptor().getTypedField(outField); } else { return null; } }
/** * Execute the statement. */ public boolean execute(DatabaseCall call, Statement statement, AbstractSession session) throws SQLException { boolean result; session.startOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL); try { if (call.isDynamicCall(session)) { result = statement.execute(call.getSQLString()); } else { result = ((PreparedStatement)statement).execute(); } } finally { session.endOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL); } return result; }
/** * Execute the statement. */ public boolean execute(DatabaseCall call, Statement statement, AbstractSession session) throws SQLException { boolean result; session.startOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL); try { if (call.isDynamicCall(session)) { result = statement.execute(call.getSQLString()); } else { result = ((PreparedStatement)statement).execute(); } } finally { session.endOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL); } return result; }
/** * Bind the parameter. Binding is determined by the call and second the platform. */ public void bindParameter(Writer writer, Object parameter) { if (parameter instanceof Collection) { throw QueryException.inCannotBeParameterized(getQuery()); } try { writer.write("?"); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().addElement(parameter); }
/** * Bind the parameter. Binding is determined by the call and second the platform. */ public void bindParameter(Writer writer, Object parameter) { if (parameter instanceof Collection) { throw QueryException.inCannotBeParameterized(getQuery()); } try { writer.write("?"); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().add(parameter); }
/** * Bind the parameter. Binding is determined by the call and second the platform. */ public void bindParameter(Writer writer, Object parameter) { if (parameter instanceof Collection) { throw QueryException.inCannotBeParameterized(getQuery()); } try { writer.write("?"); } catch (IOException exception) { throw ValidationException.fileError(exception); } getParameters().add(parameter); }
/** * Fetch the locator(s) from the result set and write LOB value to the table */ public void fetchLocatorAndWriteValue(DatabaseCall dbCall, Object resultSet) throws SQLException { Enumeration enumFields = dbCall.getContexts().getFields().elements(); Enumeration enumValues = dbCall.getContexts().getValues().elements(); AbstractSession executionSession = dbCall.getQuery().getSession().getExecutionSession(dbCall.getQuery()); while (enumFields.hasMoreElements()) { DatabaseField field = (DatabaseField)enumFields.nextElement(); Object value = enumValues.nextElement(); //write the value through the locator executionSession.getPlatform().writeLOB(field, value, (ResultSet)resultSet, executionSession); } }
/** * Fetch the locator(s) from the result set and write LOB value to the table */ public void fetchLocatorAndWriteValue(DatabaseCall dbCall, Object resultSet) throws SQLException { Enumeration enumFields = dbCall.getContexts().getFields().elements(); Enumeration enumValues = dbCall.getContexts().getValues().elements(); AbstractSession executionSession = dbCall.getQuery().getSession().getExecutionSession(dbCall.getQuery()); while (enumFields.hasMoreElements()) { DatabaseField field = (DatabaseField)enumFields.nextElement(); Object value = enumValues.nextElement(); //write the value through the locator executionSession.getPlatform().writeLOB(field, value, (ResultSet)resultSet, executionSession); } }
/** * Fetch the locator(s) from the result set and write LOB value to the table */ public void fetchLocatorAndWriteValue(DatabaseCall dbCall, Object resultSet) throws SQLException { Enumeration enumFields = dbCall.getContexts().getFields().elements(); Enumeration enumValues = dbCall.getContexts().getValues().elements(); AbstractSession executionSession = dbCall.getQuery().getSession().getExecutionSession(dbCall.getQuery()); while (enumFields.hasMoreElements()) { DatabaseField field = (DatabaseField)enumFields.nextElement(); Object value = enumValues.nextElement(); //write the value through the locator executionSession.getPlatform().writeLOB(field, value, (ResultSet)resultSet, executionSession); } }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
/** * Return the SQL string for logging purposes. */ public String getLogString(Accessor accessor) { if (hasParameters()) { StringWriter writer = new StringWriter(); writer.write(getSQLString()); writer.write(Helper.cr()); if (hasParameters()) { AbstractSession session = null; if (getQuery() != null) { session = getQuery().getSession(); } appendLogParameters(getParameters(), accessor, writer, session); } return writer.toString(); } else { return getSQLString(); } }
/** * Return the SQL string for logging purposes. */ public String getLogString(Accessor accessor) { if (hasParameters()) { StringWriter writer = new StringWriter(); writer.write(getSQLString()); writer.write(Helper.cr()); if (hasParameters()) { AbstractSession session = null; if (getQuery() != null) { session = getQuery().getSession(); } appendLogParameters(getParameters(), accessor, writer, session); } return writer.toString(); } else { return getSQLString(); } }
/** * Execute the statement. */ protected Integer executeNoSelect(DatabaseCall call, Statement statement, AbstractSession session) throws DatabaseException { Integer rowCount = executeDirectNoSelect(statement, call, session); // Allow for procs with outputs to be raised as events for error handling. if (call.shouldBuildOutputRow()) { AbstractRecord outputRow = buildOutputRow((CallableStatement)statement, call, session); call.getQuery().setProperty("output", outputRow); if (session.hasEventManager()) { session.getEventManager().outputParametersDetected(outputRow, call); } } return rowCount; }
/** * Execute the statement. */ protected Integer executeNoSelect(DatabaseCall call, Statement statement, AbstractSession session) throws DatabaseException { Integer rowCount = executeDirectNoSelect(statement, call, session); // Allow for procs with outputs to be raised as events for error handling. if (call.shouldBuildOutputRow()) { AbstractRecord outputRow = buildOutputRow((CallableStatement)statement, call, session); call.getQuery().setProperty("output", outputRow); if (session.hasEventManager()) { session.getEventManager().outputParametersDetected(outputRow, call); } } return rowCount; }
/** * Execute the statement. */ protected Integer executeNoSelect(DatabaseCall call, Statement statement, AbstractSession session) throws DatabaseException { Integer rowCount = executeDirectNoSelect(statement, call, session); // Allow for procs with outputs to be raised as events for error handling. if (call.shouldBuildOutputRow()) { AbstractRecord outputRow = buildOutputRow((CallableStatement)statement, call, session); call.getQuery().setProperty("output", outputRow); if (session.hasEventManager()) { session.getEventManager().outputParametersDetected(outputRow, call); } } return rowCount; }