Class ResultSetMappingQuery

All Implemented Interfaces:
Serializable, Cloneable

public class ResultSetMappingQuery extends ObjectBuildingQuery

Purpose: Concrete class to perform read using raw SQL and the SQLResultSetMapping.

Responsibilities: Execute a selecting raw SQL string. Returns a List of results. Each item in the list will be another list consisting of the expected populated return types in the order they were specified in the SQLResultSetMapping

Since:
TopLink Java Essentials
See Also:
  • Field Details

    • isExecuteCall

      protected boolean isExecuteCall
    • returnNameValuePairs

      protected boolean returnNameValuePairs
    • resultRows

      protected Vector resultRows
    • resultSetMappingNames

      protected List<String> resultSetMappingNames
    • resultSetMappings

      protected List<SQLResultSetMapping> resultSetMappings
  • Constructor Details

    • ResultSetMappingQuery

      public ResultSetMappingQuery()
      PUBLIC: Initialize the state of the query.
    • ResultSetMappingQuery

      public ResultSetMappingQuery(Call call)
      PUBLIC: Initialize the query to use the specified call.
    • ResultSetMappingQuery

      public ResultSetMappingQuery(Call call, String sqlResultSetMappingName)
      PUBLIC: Initialize the query to use the specified call and SQLResultSetMapping
  • Method Details

    • addSQLResultSetMapping

      public void addSQLResultSetMapping(SQLResultSetMapping resultSetMapping)
      PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
    • addSQLResultSetMappingName

      public void addSQLResultSetMappingName(String name)
      PUBLIC: Add a SQLResultSetMapping that is used by this query to process the database results.
    • cacheResult

      public void cacheResult(Object unwrappedOriginal)
      INTERNAL:

      This method is called by the object builder when building an original. It will cause the original to be cached in the query results if the query is set to do so.

      Specified by:
      cacheResult in class ReadQuery
    • convertClassNamesToClasses

      public void convertClassNamesToClasses(ClassLoader classLoader)
      INTERNAL: Convert all the class-name-based settings in this ResultSetMapping to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.
      Overrides:
      convertClassNamesToClasses in class ObjectBuildingQuery
    • shouldReturnNameValuePairs

      public boolean shouldReturnNameValuePairs()
      Indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.
    • setShouldReturnNameValuePairs

      public void setShouldReturnNameValuePairs(boolean returnNameValuePairs)
      Set the flag that indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.
    • setSQLResultSetMapping

      public void setSQLResultSetMapping(SQLResultSetMapping resultSetMapping)
      PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
    • setSQLResultSetMappings

      public void setSQLResultSetMappings(List<SQLResultSetMapping> resultSetMappings)
      PUBLIC: This will be the SQLResultSetMappings that are used by this query to process the database results
    • setSQLResultSetMappingName

      public void setSQLResultSetMappingName(String name)
      PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
    • setSQLResultSetMappingNames

      public void setSQLResultSetMappingNames(List<String> names)
      PUBLIC: This will be the SQLResult
    • buildObjectsFromRecords

      public List buildObjectsFromRecords(List databaseRecords)
      INTERNAL: This method is used to build the results. Interpreting the SQLResultSetMapping(s).
    • buildObjectsFromRecords

      public List buildObjectsFromRecords(List databaseRecords, int index)
      INTERNAL: This method is used to build the results with the SQLResultSetMapping at the given index.
    • buildObjectsFromRecords

      protected List buildObjectsFromRecords(List databaseRecords, SQLResultSetMapping mapping)
      INTERNAL: This method is used to build the results. Interpreting the SQLResultSetMapping.
    • executeDatabaseQuery

      public Object executeDatabaseQuery() throws DatabaseException
      INTERNAL: Executes the prepared query on the datastore.
      Specified by:
      executeDatabaseQuery in class DatabaseQuery
      Returns:
      - the result of executing the query.
      Throws:
      DatabaseException - - an error has occurred on the database.
    • hasResultSetMappings

      public boolean hasResultSetMappings()
      PUBLIC: Return true if there are results set mappings associated with this query.
    • isResultSetMappingQuery

      public boolean isResultSetMappingQuery()
      PUBLIC: Return true if this is a result set mapping query.
      Overrides:
      isResultSetMappingQuery in class DatabaseQuery
    • prepare

      protected void prepare()
      INTERNAL: Prepare the receiver for execution in a session.
      Overrides:
      prepare in class ReadQuery
    • getSQLResultSetMapping

      public SQLResultSetMapping getSQLResultSetMapping()
      PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
    • getSQLResultSetMappings

      public List<SQLResultSetMapping> getSQLResultSetMappings()
      PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
    • getSQLResultSetMappingName

      public String getSQLResultSetMappingName()
      PUBLIC: Return the result set mapping name.
    • getSQLResultSetMappingNames

      public List<String> getSQLResultSetMappingNames()
      PUBLIC: Return the result set mapping name.
    • setIsExecuteCall

      public void setIsExecuteCall(boolean isExecuteCall)
      PUBLIC: Set to true if you the actual jdbc result set returned from query execution. This will unprepare the query in case it was executed previously for a getResultList() call instead (or vice versa)