Class StatementClassMapping
java.lang.Object
org.datanucleus.store.rdbms.query.StatementClassMapping
Definition of statement mapping for a particular class.
Provides a definition of how the results of a datastore query are mapped on to the fields of a class.
If we take the example of this being the candidate class retrieved, then the memberName will be null
and any children represent persistent objects also retrieved in this statement. So we process all fields
in the result-set for this class, then instantiate any child object (with its id field(s)), and process all of its fields, etc.
We can have a result set with fields for multiple objects and instantiate more than 1 related object. To give an example of what an object of this type can look like
StatementClassMapping:class=null,member=null,mappings= [ {field=0,mapping=mapping: org.datanucleus.store.rdbms.mapping.IntegerMapping@5995c31c column(s): [2]}, {field=1,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@5947d51d column(s): [3]}, {field=2,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@585e7d87 column(s): [7]}, {field=-2,mapping=mapping: org.datanucleus.store.rdbms.mapping.VersionLongMapping@ce796 column(s): [11]}, ], children= [ {field=1,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=next,mappings= [ {field=0,mapping=mapping: org.datanucleus.store.rdbms.mapping.IntegerMapping@5995c31c column(s): [3]}, {field=1,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@5947d51d column(s): [4]}, {field=2,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@585e7d87 column(s): [5]}, {field=-2,mapping=mapping: org.datanucleus.store.rdbms.mapping.VersionLongMapping@ce796 column(s): [6]} ]}, {field=2,mapping=StatementClassMapping:class=org.datanucleus.test.CircRef,member=prev,mappings= [ {field=0,mapping=mapping: org.datanucleus.store.rdbms.mapping.IntegerMapping@5995c31c column(s): [7]}, {field=1,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@5947d51d column(s): [8]}, {field=2,mapping=mapping: org.datanucleus.store.rdbms.mapping.PersistableMapping@585e7d87 column(s): [9]}, {field=-2,mapping=mapping: org.datanucleus.store.rdbms.mapping.VersionLongMapping@ce796 column(s): [10]} ]} ]In this example we have a persistable object as candidate, and it has 2 1-1 relations (field=1, field=2). These are both being retrieved in the same query, hence the sub-mappings. Note that the column(s) of the FK in the owner object is the same as the PK field(s) of the related object.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Map
<Integer, StatementClassMapping> Mapping definition for a member that is a relation in this statement, keyed by the member number.(package private) String
Name of the class.(package private) String
Name of a DN_TYPE column if used in this query for determining this class.(package private) Map
<Integer, StatementMappingIndex> Mappings for the members of this object defined in the statement, keyed by the member number.(package private) String
Name of the field/property in the parent class (null implies parent class).(package private) int[]
Numbers of fields/properties defined in the statement. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMappingDefinitionForMember
(int position, StatementClassMapping defn) void
addMappingForMember
(int position, StatementMappingIndex mapping) getMappingDefinitionForMemberPosition
(int position) Accessor for the mapping definition for the object at the specified member position.getMappingForMemberPosition
(int position) Accessor for the mapping information for the member at the specified position.int[]
Accessor for the numbers of the members present.boolean
Accessor for whether this definition has child object definitions.void
setNucleusTypeColumnName
(String colName) toString()
-
Field Details
-
className
String classNameName of the class. -
memberName
String memberNameName of the field/property in the parent class (null implies parent class). -
dnTypeColumn
String dnTypeColumnName of a DN_TYPE column if used in this query for determining this class. Null otherwise. -
memberNumbers
int[] memberNumbersNumbers of fields/properties defined in the statement. -
mappings
Map<Integer,StatementMappingIndex> mappingsMappings for the members of this object defined in the statement, keyed by the member number. -
children
Map<Integer,StatementClassMapping> childrenMapping definition for a member that is a relation in this statement, keyed by the member number.
-
-
Constructor Details
-
StatementClassMapping
public StatementClassMapping() -
StatementClassMapping
-
-
Method Details
-
getClassName
-
getMemberName
-
setNucleusTypeColumnName
-
getNucleusTypeColumnName
-
getMappingForMemberPosition
Accessor for the mapping information for the member at the specified position. Member positions start at 0 (first member in the root persistent class). Member position of -1 means datastore-identity. Member position of -2 means version. Member position of -3 means discriminator.- Parameters:
position
- The member position- Returns:
- The mapping information
-
getMappingDefinitionForMemberPosition
Accessor for the mapping definition for the object at the specified member position. Returns null if the member is not a relation field. Member positions start at 0 (first member in the root persistent class). Member position of -1 means datastore-identity. Member position of -2 means version. Member position of -3 means discriminator. Member position of -4 means multitenancy.- Parameters:
position
- The position of the member in this class- Returns:
- The mapping definition for the object at this member position
-
hasChildMappingDefinitions
public boolean hasChildMappingDefinitions()Accessor for whether this definition has child object definitions.- Returns:
- Whether there are sub-objects of this object mapped.
-
getMemberNumbers
public int[] getMemberNumbers()Accessor for the numbers of the members present. Doesn't include any surrogate numbers since not real members.- Returns:
- The member positions
-
addMappingForMember
-
addMappingDefinitionForMember
-
cloneStatementMappingWithoutChildren
-
toString
-