|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.store.rdbms.sql.SQLStatementHelper
public class SQLStatementHelper
Series of convenience methods to help the process of generating SQLStatements.
| Constructor Summary | |
|---|---|
SQLStatementHelper()
|
|
| Method Summary | |
|---|---|
static SQLTable |
addJoinForOneToOneRelation(SQLStatement stmt,
org.datanucleus.store.mapped.mapping.JavaTypeMapping sourceMapping,
SQLTable sourceSqlTbl,
org.datanucleus.store.mapped.mapping.JavaTypeMapping targetMapping,
org.datanucleus.store.mapped.DatastoreContainerObject targetTable,
String targetAlias,
Object[] discrimValues,
String targetTablegroupName,
SQLJoin.JoinType joinType)
Convenience method to add a join across a 1-1 relation to the provided SQLStatement. |
static void |
applyParametersToStatement(PreparedStatement ps,
org.datanucleus.store.ExecutionContext ec,
List<SQLStatementParameter> parameters,
Map<Integer,String> paramNameByPosition,
Map paramValuesByName)
Convenience method to apply parameter values to the provided statement. |
static List |
getDiscriminatorValuesForMember(String className,
org.datanucleus.store.mapped.mapping.JavaTypeMapping discMapping,
RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
Method to return all possible discriminator values for the supplied class and its subclasses. |
static BooleanExpression |
getExpressionForDiscriminatorForClass(SQLStatement stmt,
String className,
org.datanucleus.metadata.DiscriminatorMetaData dismd,
org.datanucleus.store.mapped.mapping.JavaTypeMapping discriminatorMapping,
SQLTable discrimSqlTbl,
org.datanucleus.ClassLoaderResolver clr)
Convenience method to generate a BooleanExpression for the associated discriminator value for the specified class. |
static PreparedStatement |
getPreparedStatementForSQLStatement(SQLStatement sqlStmt,
org.datanucleus.store.ExecutionContext ec,
org.datanucleus.store.connection.ManagedConnection mconn,
String resultSetType,
String resultSetConcurrency)
Convenience method to return a PreparedStatement for an SQLStatement. |
static SQLTable |
getSQLTableForMappingOfTable(SQLStatement stmt,
SQLTable sqlTbl,
org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
Method to return the SQLTable where the specified mapping (in the same table group as the provided SQLTable) is defined. |
static Object |
getValueForPrimaryKeyIndexOfObjectUsingReflection(Object value,
int index,
org.datanucleus.metadata.AbstractClassMetaData cmd,
org.datanucleus.store.mapped.MappedStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
Convenience method to use reflection to extract the value of a PK field of the provided object. |
static void |
selectFetchPlanOfCandidateInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.metadata.AbstractClassMetaData candidateCmd,
org.datanucleus.FetchPlan fetchPlan,
int maxFetchDepth)
Method to select all fetch plan members for the candidate class. |
static void |
selectFetchPlanOfSourceClassInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.FetchPlan fetchPlan,
SQLTable sourceSqlTbl,
org.datanucleus.metadata.AbstractClassMetaData sourceCmd,
int maxFetchDepth)
Method to select all fetch plan members for the "source" class. |
static void |
selectIdentityOfCandidateInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to select the identity for the candidate class. |
static void |
selectMemberOfSourceInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.FetchPlan fetchPlan,
SQLTable sourceSqlTbl,
org.datanucleus.metadata.AbstractMemberMetaData mmd,
org.datanucleus.ClassLoaderResolver clr,
int maxFetchPlanLimit)
Method to select the specified member (field/property) of the source table in the passed SQL statement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SQLStatementHelper()
| Method Detail |
|---|
public static PreparedStatement getPreparedStatementForSQLStatement(SQLStatement sqlStmt,
org.datanucleus.store.ExecutionContext ec,
org.datanucleus.store.connection.ManagedConnection mconn,
String resultSetType,
String resultSetConcurrency)
throws SQLException
sqlStmt - The query expressionec - execution contextmconn - The connection to useresultSetType - Type of result set (if any)resultSetConcurrency - result-set concurrency (if any)
SQLException - If an error occurs in creation
public static void applyParametersToStatement(PreparedStatement ps,
org.datanucleus.store.ExecutionContext ec,
List<SQLStatementParameter> parameters,
Map<Integer,String> paramNameByPosition,
Map paramValuesByName)
ps - The prepared statementec - ObjectManagerparameters - The parametersparamNameByPosition - Optional map of parameter names keyed by the positionparamValuesByName - Value of parameter keyed by name (or position)
public static Object getValueForPrimaryKeyIndexOfObjectUsingReflection(Object value,
int index,
org.datanucleus.metadata.AbstractClassMetaData cmd,
org.datanucleus.store.mapped.MappedStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
value - The value of the overall objectindex - Index of the PK field whose value we need to returncmd - Metadata for the classstoreMgr - Store managerclr - ClassLoader resolver
public static SQLTable getSQLTableForMappingOfTable(SQLStatement stmt,
SQLTable sqlTbl,
org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
stmt - The statementsqlTbl - SQLTable to start from for the supplied mapping (may be in super-table,
or secondary-table of this)mapping - The mapping
public static void selectIdentityOfCandidateInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
stmt - The statementmappingDefinition - Mapping definition for result columnscandidateCmd - The candidate class meta-data
public static void selectFetchPlanOfCandidateInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.metadata.AbstractClassMetaData candidateCmd,
org.datanucleus.FetchPlan fetchPlan,
int maxFetchDepth)
stmt - The statementmappingDefinition - Mapping definition for result columnscandidateCmd - The candidate class meta-datafetchPlan - FetchPlan in usemaxFetchDepth - Max fetch depth from this point to select (0 implies no other objects)
public static void selectFetchPlanOfSourceClassInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.FetchPlan fetchPlan,
SQLTable sourceSqlTbl,
org.datanucleus.metadata.AbstractClassMetaData sourceCmd,
int maxFetchDepth)
stmt - The statementmappingDefinition - Mapping definition for result columns (populated with column positions
of any selected mappings if provided as input)fetchPlan - FetchPlan in usesourceSqlTbl - SQLTable for the source class that we select fromsourceCmd - Meta-data for the source classmaxFetchDepth - Max fetch depth from this point to select (0 implies no other objects)
public static void selectMemberOfSourceInStatement(SQLStatement stmt,
org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
org.datanucleus.FetchPlan fetchPlan,
SQLTable sourceSqlTbl,
org.datanucleus.metadata.AbstractMemberMetaData mmd,
org.datanucleus.ClassLoaderResolver clr,
int maxFetchPlanLimit)
stmt - The SQL statementmappingDefinition - Mapping definition for the results (will be populated by any
selected mappings if provided as input)fetchPlan - FetchPlansourceSqlTbl - Table that has the member (or a super-table/secondary-table of this table)mmd - Meta-data for the field/property in the source that we are selectingclr - ClassLoader resolvermaxFetchPlanLimit - Max fetch depth from this point to select (0 implies no other objects)
public static SQLTable addJoinForOneToOneRelation(SQLStatement stmt,
org.datanucleus.store.mapped.mapping.JavaTypeMapping sourceMapping,
SQLTable sourceSqlTbl,
org.datanucleus.store.mapped.mapping.JavaTypeMapping targetMapping,
org.datanucleus.store.mapped.DatastoreContainerObject targetTable,
String targetAlias,
Object[] discrimValues,
String targetTablegroupName,
SQLJoin.JoinType joinType)
stmt - The SQLStatementsourceMapping - Mapping of the relation in the source tablesourceSqlTbl - Source table in the SQLStatementtargetMapping - Mapping of the relation in the target tabletargetTable - Target table in the datastoretargetAlias - Alias for target table to use in SQLStatementdiscrimValues - Any discriminator values to apply to restrict the target side (if any)targetTablegroupName - Name of the tablegroup that the target SQLTable should be in (if known)joinType - Type of join to use (if known). If not known will use based on whether nullable
public static BooleanExpression getExpressionForDiscriminatorForClass(SQLStatement stmt,
String className,
org.datanucleus.metadata.DiscriminatorMetaData dismd,
org.datanucleus.store.mapped.mapping.JavaTypeMapping discriminatorMapping,
SQLTable discrimSqlTbl,
org.datanucleus.ClassLoaderResolver clr)
stmt - The Query Statement to be updatedclassName - The class namedismd - MetaData for the discriminatordiscriminatorMapping - Mapping for the discriminatordiscrimSqlTbl - SQLTable for the table with the discriminatorclr - ClassLoader resolver
public static List getDiscriminatorValuesForMember(String className,
org.datanucleus.store.mapped.mapping.JavaTypeMapping discMapping,
RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
className - Name of the classdiscMapping - The discriminator mappingstoreMgr - StoreManagerclr - ClassLoader resolver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||