All Implemented Interfaces:
Serializable, Cloneable, QueryStringCall, Call

public class SQLCall extends DatabaseCall implements QueryStringCall
Purpose: Used as an abstraction of an SQL call. A call is an SQL string with parameters.
See Also:
  • Field Details

    • hasCustomSQLArguments

      protected boolean hasCustomSQLArguments
    • isTranslatedCustomQuery

      protected transient boolean isTranslatedCustomQuery
  • Constructor Details

    • SQLCall

      public SQLCall()
      PUBLIC: Create a new SQL call.
    • SQLCall

      public SQLCall(String sqlString)
      PUBLIC: Create a new SQL call. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
  • Method Details

    • afterTranslateCustomQuery

      protected void afterTranslateCustomQuery(List updatedParameters, List<DatasourceCall.ParameterType> updatedParameterTypes)
      INTERNAL: Set the data passed through setCustomSQLArgumentType and useCustomSQLCursorOutputAsResultSet methods.
    • afterTranslateCustomQueryUpdateParameter

      protected DatabaseField afterTranslateCustomQueryUpdateParameter(DatabaseField field, int index, DatasourceCall.ParameterType parameterType, List updatedParameters, List<DatasourceCall.ParameterType> updatedParameterTypes)
      INTERNAL: Set the data passed through setCustomSQLArgumentType and useCustomSQLCursorOutputAsResultSet methods. This will return the null if the user did not add the field/type using the setCustomSQLArgumentType method
    • hasCustomSQLArguments

      public boolean hasCustomSQLArguments()
      INTERNAL: Used to avoid misinterpreting the # in custom SQL.
    • isSQLCall

      public boolean isSQLCall()
      Overrides:
      isSQLCall in class DatasourceCall
    • isQueryStringCall

      public boolean isQueryStringCall()
      Description copied from interface: QueryStringCall
      Should return true.
      Specified by:
      isQueryStringCall in interface QueryStringCall
      Overrides:
      isQueryStringCall in class DatasourceCall
    • prepareInternal

      protected void prepareInternal(AbstractSession session)
      INTERNAL: Called by prepare method only.
      Overrides:
      prepareInternal in class DatabaseCall
    • setHasCustomSQLArguments

      public void setHasCustomSQLArguments(boolean hasCustomSQLArguments)
      INTERNAL: Used to avoid misinterpreting the # in custom SQL.
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String customParameterName, Class<?> type)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string).
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String argumentFieldName, int type)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string). The argumentFieldName is the field or argument name used in the SQL. The type is the JDBC type code for the parameter.
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String argumentFieldName, int type, String typeName)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string). The argumentFieldName is the field or argument name used in the SQL. The type is the JDBC type code for the parameter. The typeName is the JDBC type name, this may be required for ARRAY or STRUCT types.
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String argumentFieldName, int type, String typeName, Class<?> javaType)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string). TThe argumentFieldName is the field or argument name used in the SQL. The type is the JDBC type code for the parameter. The typeName is the JDBC type name, this may be required for ARRAY or STRUCT types. The javaType is the java class to return instead of the ARRAY and STRUCT types if a conversion is possible.
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String argumentFieldName, int type, String typeName, DatabaseField nestedType)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string). TThe argumentFieldName is the field or argument name used in the SQL. The type is the JDBC type code for the parameter. The typeName is the JDBC type name, this may be required for ARRAY or STRUCT types. The nestedType is a DatabaseField with type information set to match the VARRAYs object types
    • setCustomSQLArgumentType

      public void setCustomSQLArgumentType(String argumentFieldName, int type, String typeName, Class<?> javaType, DatabaseField nestedType)
      PUBLIC: This method should only be used with custom SQL: it sets a type to IN, OUT or INOUT parameter (prefixed with #, ### or #### in custom SQL string). TThe argumentFieldName is the field or argument name used in the SQL. The type is the JDBC type code for the parameter. The typeName is the JDBC type name, this may be required for ARRAY or STRUCT types. The javaType is the java class to return instead of the ARRAY and STRUCT types if a conversion is possible. The nestedType is a DatabaseField with type information set to match the VARRAYs object types
    • setSQLString

      public void setSQLString(String sqlString)
      Set the SQL string. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
    • translateCustomQuery

      public void translateCustomQuery()
      INTERNAL: Keep track of the fact that this call has been translated. This information is used to ensure the translation code for a custom SQLCall is only run once In the case of inheritance we will try to call the translation code once to get the list of types and again for each subclass
      Specified by:
      translateCustomQuery in interface QueryStringCall
      Overrides:
      translateCustomQuery in class DatasourceCall
    • translatePureSQLCustomQuery

      public void translatePureSQLCustomQuery()
      INTERNAL: Only translate the call if it was not previously translated This code ensures the translation code for a custom SQLCall is only run once In the case of inheritance we will try to call the translation code once to get the list of types and again for each subclass
      Overrides:
      translatePureSQLCustomQuery in class DatasourceCall
    • appendTranslationParameter

      public void appendTranslationParameter(Writer writer, ParameterExpression expression, DatabasePlatform platform, AbstractRecord record) throws IOException
      INTERNAL: All values are printed as ? to allow for parameter binding or translation during the execute of the call.
      Throws:
      IOException
    • useCustomSQLCursorOutputAsResultSet

      public void useCustomSQLCursorOutputAsResultSet(String customParameterName)
      PUBLIC: This method should only be used with custom SQL: Used for Oracle result sets through procedures. It defines OUT parameter (prefixed with ### in custom SQL string) as a cursor output.