Class StatementClassMapping
- java.lang.Object
-
- org.datanucleus.store.rdbms.query.StatementClassMapping
-
public class StatementClassMapping extends Object
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.
-
-
Constructor Summary
Constructors Constructor Description StatementClassMapping()
StatementClassMapping(String className, String memberName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMappingDefinitionForMember(int position, StatementClassMapping defn)
void
addMappingForMember(int position, StatementMappingIndex mapping)
StatementClassMapping
cloneStatementMappingWithoutChildren()
String
getClassName()
StatementClassMapping
getMappingDefinitionForMemberPosition(int position)
Accessor for the mapping definition for the object at the specified member position.StatementMappingIndex
getMappingForMemberPosition(int position)
Accessor for the mapping information for the member at the specified position.String
getMemberName()
int[]
getMemberNumbers()
Accessor for the numbers of the members present.String
getNucleusTypeColumnName()
boolean
hasChildMappingDefinitions()
Accessor for whether this definition has child object definitions.void
setNucleusTypeColumnName(String colName)
String
toString()
-
-
-
Method Detail
-
getClassName
public String getClassName()
-
getMemberName
public String getMemberName()
-
setNucleusTypeColumnName
public void setNucleusTypeColumnName(String colName)
-
getNucleusTypeColumnName
public String getNucleusTypeColumnName()
-
getMappingForMemberPosition
public StatementMappingIndex getMappingForMemberPosition(int position)
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
public StatementClassMapping getMappingDefinitionForMemberPosition(int position)
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
public void addMappingForMember(int position, StatementMappingIndex mapping)
-
addMappingDefinitionForMember
public void addMappingDefinitionForMember(int position, StatementClassMapping defn)
-
cloneStatementMappingWithoutChildren
public StatementClassMapping cloneStatementMappingWithoutChildren()
-
-