Class StatementMappingIndex
java.lang.Object
org.datanucleus.store.rdbms.query.StatementMappingIndex
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
...
}
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) StringAny name applied in the field selection (SELECT xxx AS yyy).(package private) int[]Positions for the column(s) for this field in the result clause of a statement.(package private) JavaTypeMappingMapping being represented.(package private) List<int[]> Positions where this mapping is a parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameterOccurrence(int[] positions) Method to register statement position(s) that this mapping is used as a parameter.Accessor for the column name alias (if any).int[]Accessor for the column position(s).intAccessor 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.voidremoveParameterOccurrence(int[] positions) Method to deregister statement positions that this mapping is used as a parameter.voidsetColumnAlias(String alias) Mutator for the column name (alias).voidsetColumnPositions(int[] pos) Mutator for the column positions in the result clause of a statement.voidsetMapping(JavaTypeMapping mapping) toString()Method to return a string version of this object.
-
Field Details
-
mapping
JavaTypeMapping mappingMapping being represented. -
columnPositions
int[] columnPositionsPositions for the column(s) for this field in the result clause of a statement. -
paramPositions
List<int[]> paramPositionsPositions where this mapping is a parameter. Each usage of the mapping has n parameter positions. -
columnName
String columnNameAny name applied in the field selection (SELECT xxx AS yyy). Only applies for cases with 1 column.
-
-
Constructor Details
-
StatementMappingIndex
-
-
Method Details
-
getMapping
-
setMapping
-
getColumnAlias
Accessor for the column name alias (if any). Only applies to the first column for this field.- Returns:
- The column alias.
-
setColumnAlias
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
-
toString
-