Class StatementMappingIndex
- java.lang.Object
-
- org.datanucleus.store.rdbms.query.StatementMappingIndex
-
public class StatementMappingIndex extends Object
Representation of a mapping in a statement (such as JDBC), and its mapping to the associated column(s) or parameters that the mapping relates to. The mapping may be for a field of a class (whether it is a real field or a surrogate), or for a parameter.- Provides index positions of the column(s) of this field in the result clause of the statement
- Provides parameter position(s) if any of the column(s) are statement parameters, for input
CLASS FIELDNUM MAPPING TABLE COLUMN POSITIONS ----------------- -------- -------------- ---------------- ---------------- class A TABLE_A { short fieldA; 1 ShortMapping COL_FIELDA 1 String fieldB; 2 StringMapping COL_FIELDB_PART1 2 COL_FIELDB_PART2 3 ... }
-
-
Constructor Summary
Constructors Constructor Description StatementMappingIndex(JavaTypeMapping mapping)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParameterOccurrence(int[] positions)
Method to register statement position(s) that this mapping is used as a parameter.String
getColumnAlias()
Accessor for the column name alias (if any).int[]
getColumnPositions()
Accessor for the column position(s).JavaTypeMapping
getMapping()
int
getNumberOfParameterOccurrences()
Accessor for the number of times this mapping is used as a parameter.int[]
getParameterPositionsForOccurrence(int num)
Accessor for the parameter positions for this occurrence of use of the mapping as a parameter.void
removeParameterOccurrence(int[] positions)
Method to deregister statement positions that this mapping is used as a parameter.void
setColumnAlias(String alias)
Mutator for the column name (alias).void
setColumnPositions(int[] pos)
Mutator for the column positions in the result clause of a statement.void
setMapping(JavaTypeMapping mapping)
String
toString()
Method to return a string version of this object.
-
-
-
Constructor Detail
-
StatementMappingIndex
public StatementMappingIndex(JavaTypeMapping mapping)
-
-
Method Detail
-
getMapping
public JavaTypeMapping getMapping()
-
setMapping
public void setMapping(JavaTypeMapping mapping)
-
getColumnAlias
public String getColumnAlias()
Accessor for the column name alias (if any). Only applies to the first column for this field.- Returns:
- The column alias.
-
setColumnAlias
public void setColumnAlias(String alias)
Mutator for the column name (alias). Overrides the name of the field that the mapping refers to.- Parameters:
alias
- The name of the column (alias).
-
getColumnPositions
public int[] getColumnPositions()
Accessor for the column position(s).- Returns:
- The column position(s) in the result clause of the statement.
-
setColumnPositions
public void setColumnPositions(int[] pos)
Mutator for the column positions in the result clause of a statement.- Parameters:
pos
- The column position(s)
-
addParameterOccurrence
public void addParameterOccurrence(int[] positions)
Method to register statement position(s) that this mapping is used as a parameter. The number of positions must be the same as the mapping number of columns.- Parameters:
positions
- The parameter positions in the statement.
-
removeParameterOccurrence
public void removeParameterOccurrence(int[] positions)
Method to deregister statement positions that this mapping is used as a parameter.- Parameters:
positions
- The param positions to deregister
-
getNumberOfParameterOccurrences
public int getNumberOfParameterOccurrences()
Accessor for the number of times this mapping is used as a parameter.- Returns:
- Number of times used as a parameter
-
getParameterPositionsForOccurrence
public int[] getParameterPositionsForOccurrence(int num)
Accessor for the parameter positions for this occurrence of use of the mapping as a parameter.- Parameters:
num
- The occurrence of using this mapping as a parameter.- Returns:
- The parameter positions
-
-