Class RDBMSQueryUtils

java.lang.Object
org.datanucleus.store.query.QueryUtils
org.datanucleus.store.rdbms.query.RDBMSQueryUtils

public class RDBMSQueryUtils extends org.datanucleus.store.query.QueryUtils
Utilities for use in queries specific to RDBMS.
  • Field Details

    • QUERY_RESULTSET_TYPE_SCROLL_SENSITIVE

      public static final String QUERY_RESULTSET_TYPE_SCROLL_SENSITIVE
      See Also:
    • QUERY_RESULTSET_TYPE_SCROLL_INSENSITIVE

      public static final String QUERY_RESULTSET_TYPE_SCROLL_INSENSITIVE
      See Also:
    • QUERY_RESULTSET_TYPE_FORWARD_ONLY

      public static final String QUERY_RESULTSET_TYPE_FORWARD_ONLY
      See Also:
    • QUERY_RESULTSET_CONCURRENCY_READONLY

      public static final String QUERY_RESULTSET_CONCURRENCY_READONLY
      See Also:
    • QUERY_RESULTSET_CONCURRENCY_UPDATEABLE

      public static final String QUERY_RESULTSET_CONCURRENCY_UPDATEABLE
      See Also:
  • Constructor Details

    • RDBMSQueryUtils

      public RDBMSQueryUtils()
  • Method Details

    • getClassNameFromDiscriminatorResultSetRow

      public static String getClassNameFromDiscriminatorResultSetRow(JavaTypeMapping discrimMapping, org.datanucleus.metadata.DiscriminatorMetaData dismd, ResultSet rs, org.datanucleus.ExecutionContext ec)
      Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents.
      Parameters:
      discrimMapping - Mapping for the discriminator column
      dismd - Metadata for the discriminator
      rs - The result set
      ec - execution context
      Returns:
      The class name for the object represented in the current row
    • getQueryResultForQuery

      public static AbstractRDBMSQueryResult getQueryResultForQuery(org.datanucleus.store.query.Query q, ResultObjectFactory rof, ResultSet rs, Collection candidates)
    • getResultSetTypeForQuery

      public static String getResultSetTypeForQuery(org.datanucleus.store.query.Query query)
      Accessor for the result set type for the specified query. Uses the persistence property "datanucleus.rdbms.query.resultSetType" and allows it to be overridden by the query extension of the same name. Checks both the NucleusContext and also the query extensions.
      Parameters:
      query - The query
      Returns:
      The result set type string
    • getResultSetConcurrencyForQuery

      public static String getResultSetConcurrencyForQuery(org.datanucleus.store.query.Query query)
      Accessor for the result set concurrency for the specified query. Uses the persistence property "datanucleus.rdbms.query.resultSetConcurrency" and allows it to be overridden by the query extension of the same name. Checks both the NucleusContext and also the query extensions.
      Parameters:
      query - The query
      Returns:
      The result set concurrency string
    • useUpdateLockForQuery

      public static boolean useUpdateLockForQuery(org.datanucleus.store.query.Query query)
      Convenience method to return if the specified query should use an "UPDATE" lock on returned objects. First checks whether serializeRead is set on the query and, if not, falls back to the setting for the class.
      Parameters:
      query - The query
      Returns:
      Whether to use an "UPDATE" lock
    • getPreparedStatementForQuery

      public static PreparedStatement getPreparedStatementForQuery(org.datanucleus.store.connection.ManagedConnection conn, String queryStmt, org.datanucleus.store.query.Query query) throws SQLException
      Method to create a PreparedStatement for use with the query.
      Parameters:
      conn - the Connection
      queryStmt - The statement text for the query
      query - The query
      Returns:
      the PreparedStatement
      Throws:
      SQLException - Thrown if an error occurs creating the statement
    • prepareStatementForExecution

      public static void prepareStatementForExecution(PreparedStatement ps, org.datanucleus.store.query.Query query, boolean applyTimeout) throws SQLException
      Method to apply any restrictions to the created ResultSet.
      Parameters:
      ps - The PreparedStatement
      query - The query
      applyTimeout - Whether to apply the query timeout (if any) direct to the PreparedStatement
      Throws:
      SQLException - Thrown when an error occurs applying the constraints
    • getStatementForCandidates

      public static SelectStatement getStatementForCandidates(RDBMSStoreManager storeMgr, SQLStatement parentStmt, org.datanucleus.metadata.AbstractClassMetaData cmd, StatementClassMapping clsMapping, org.datanucleus.ExecutionContext ec, Class candidateCls, boolean subclasses, String result, String candidateAlias, String candidateTableGroupName, Set<String> options)
      Method to return a statement selecting the candidate table(s) required to cover all possible types for this candidates inheritance strategy.
      Parameters:
      storeMgr - RDBMS StoreManager
      parentStmt - Parent statement (if there is one)
      cmd - Metadata for the class
      clsMapping - Mapping for the results of the statement
      ec - ExecutionContext
      candidateCls - Candidate class
      subclasses - Whether to create a statement for subclasses of the candidate too
      result - The result clause
      candidateAlias - alias for the candidate (if any)
      candidateTableGroupName - TableGroup name for the candidate (if any)
      options - Any options for the statement for getting candidates. See SelectStatementGenerator for some options.
      Returns:
      The SQLStatement
      Throws:
      org.datanucleus.exceptions.NucleusException - if there are no tables for concrete classes in this query (hence would return null)
    • getResultObjectFactoryForNoCandidateClass

      public static ResultObjectFactory getResultObjectFactoryForNoCandidateClass(org.datanucleus.ExecutionContext ec, ResultSet rs, Class resultClass)
      Utility to take a ResultSet and return a ResultObjectFactory for extracting the results, assuming that no candidate class is supplied. The QueryResult will return either a result class type, or Object/Object[] depending on whether a ResultClass has been defined.
      Parameters:
      ec - ExecutionContext
      rs - The ResultSet
      resultClass - Result class if required (or null)
      Returns:
      The query ResultObjectFactory