org.datanucleus.store.rdbms.query
Class RDBMSQueryUtils

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

public class RDBMSQueryUtils
extends org.datanucleus.query.QueryUtils

Utilities for use in queries specific to RDBMS.


Field Summary
 
Fields inherited from class org.datanucleus.query.QueryUtils
classArrayObjectObject, LOCALISER
 
Constructor Summary
RDBMSQueryUtils()
           
 
Method Summary
static java.lang.String getClassNameFromDiscriminatorResultSetRow(org.datanucleus.store.mapped.mapping.JavaTypeMapping discrimMapping, org.datanucleus.metadata.DiscriminatorMetaData dismd, java.sql.ResultSet rs, org.datanucleus.ObjectManager om)
          Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents.
static java.lang.String getClassNameFromDiscriminatorValue(java.lang.String discrimValue, org.datanucleus.metadata.DiscriminatorMetaData dismd, org.datanucleus.ObjectManager om)
          Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents.
static java.sql.PreparedStatement getPreparedStatementForQuery(org.datanucleus.ManagedConnection conn, org.datanucleus.store.mapped.expression.StatementText stmtText, org.datanucleus.store.query.Query query)
          Method to create a PreparedStatement for use with the query.
static java.sql.PreparedStatement getPreparedStatementForQuery(org.datanucleus.ManagedConnection conn, java.lang.String queryStmt, org.datanucleus.store.query.Query query)
          Method to create a PreparedStatement for use with the query.
static java.lang.String getResultSetConcurrencyForQuery(org.datanucleus.store.query.Query query)
          Accessor for the result set concurrency for the specified query.
static java.lang.String getResultSetTypeForQuery(org.datanucleus.store.query.Query query)
          Accessor for the result set type for the specified query.
static void prepareStatementForExecution(java.sql.PreparedStatement ps, org.datanucleus.store.query.Query query, boolean applyTimeout)
          Method to apply any restrictions to the created ResultSet.
static boolean useUpdateLockForQuery(org.datanucleus.store.query.Query query)
          Convenience method to return if the specified query should use an "UPDATE" lock on the objects returned.
 
Methods inherited from class org.datanucleus.query.QueryUtils
compareExpressionValues, createResultObjectUsingArgumentedConstructor, createResultObjectUsingDefaultConstructorAndSetters, createResultObjectUsingDefaultConstructorAndSetters, expressionHasNotOperator, expressionHasOrOperator, getExpressionsFromString, getParameterExpressionForPosition, getPublicPutMethodForResultClass, getPublicSetMethodForFieldOfResultClass, getStringValue, getStringValueForExpression, getValueForParameterExpression, queryParameterTypesAreCompatible, queryReturnsSingleRow, resultClassIsSimple, resultClassIsUserType, resultHasOnlyAggregates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDBMSQueryUtils

public RDBMSQueryUtils()
Method Detail

getClassNameFromDiscriminatorResultSetRow

public static java.lang.String getClassNameFromDiscriminatorResultSetRow(org.datanucleus.store.mapped.mapping.JavaTypeMapping discrimMapping,
                                                                         org.datanucleus.metadata.DiscriminatorMetaData dismd,
                                                                         java.sql.ResultSet rs,
                                                                         org.datanucleus.ObjectManager om)
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
om - Object Manager
Returns:
The class name for the object represented in the current row

getClassNameFromDiscriminatorValue

public static java.lang.String getClassNameFromDiscriminatorValue(java.lang.String discrimValue,
                                                                  org.datanucleus.metadata.DiscriminatorMetaData dismd,
                                                                  org.datanucleus.ObjectManager om)
Convenience method that takes a result set that contains a discriminator column and returns the class name that it represents. TODO This is not RDBMS-specific so move to generic location

Parameters:
discrimValue - Discriminator value
dismd - Metadata for the discriminator at the root (defining the strategy)
om - ObjectManager
Returns:
The class name for the object represented by this value

getResultSetTypeForQuery

public static java.lang.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 PMF, and also the query extensions.

Parameters:
query - The query
Returns:
The result set type string

getResultSetConcurrencyForQuery

public static java.lang.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 PMF, 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 the objects returned. First checks the transaction setting for locking, then the query locking and finally allows it to be overridden by the query extension "datanucleus.rdbms.query.useUpdateLock".

Parameters:
query - The query
Returns:
Whether to use an "UPDATE" lock

getPreparedStatementForQuery

public static java.sql.PreparedStatement getPreparedStatementForQuery(org.datanucleus.ManagedConnection conn,
                                                                      java.lang.String queryStmt,
                                                                      org.datanucleus.store.query.Query query)
                                                               throws java.sql.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:
java.sql.SQLException - Thrown if an error occurs creating the statement

getPreparedStatementForQuery

public static java.sql.PreparedStatement getPreparedStatementForQuery(org.datanucleus.ManagedConnection conn,
                                                                      org.datanucleus.store.mapped.expression.StatementText stmtText,
                                                                      org.datanucleus.store.query.Query query)
                                                               throws java.sql.SQLException
Method to create a PreparedStatement for use with the query.

Parameters:
conn - the Connection
stmtText - The statement text
query - The query
Returns:
the PreparedStatement
Throws:
java.sql.SQLException - Thrown if an error occurs creating the statement

prepareStatementForExecution

public static void prepareStatementForExecution(java.sql.PreparedStatement ps,
                                                org.datanucleus.store.query.Query query,
                                                boolean applyTimeout)
                                         throws java.sql.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:
java.sql.SQLException - Thrown when an error occurs applying the constraints


Copyright © 2009. All Rights Reserved.