org.datanucleus.store.mapped
Class StatementClassMapping

java.lang.Object
  extended by org.datanucleus.store.mapped.StatementClassMapping

public class StatementClassMapping
extends java.lang.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.mapped.mapping.IntegerMapping@5995c31c column(s): [2]},
    {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [3]},
    {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [7]},
    {field=-2,mapping=mapping: org.datanucleus.store.mapped.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.mapped.mapping.IntegerMapping@5995c31c column(s): [3]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [4]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [5]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.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.mapped.mapping.IntegerMapping@5995c31c column(s): [7]},
            {field=1,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@5947d51d column(s): [8]},
            {field=2,mapping=mapping: org.datanucleus.store.mapped.mapping.PersistableMapping@585e7d87 column(s): [9]},
            {field=-2,mapping=mapping: org.datanucleus.store.mapped.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
static int MEMBER_DATASTORE_ID
           
static int MEMBER_DISCRIMINATOR
           
static int MEMBER_VERSION
           
 
Constructor Summary
StatementClassMapping()
           
StatementClassMapping(java.lang.String memberName)
           
StatementClassMapping(java.lang.String className, java.lang.String memberName)
           
 
Method Summary
 void addMappingDefinitionForMember(int position, StatementClassMapping defn)
           
 void addMappingForMember(int position, StatementMappingIndex mapping)
           
 StatementClassMapping cloneStatementMappingWithoutChildren()
           
 java.lang.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.
 java.lang.String getMemberName()
           
 int[] getMemberNumbers()
          Accessor for the numbers of the members present.
 java.lang.String getNucleusTypeColumnName()
           
 boolean hasChildMappingDefinitions()
          Accessor for whether this definition has child object definitions.
 void setNucleusTypeColumnName(java.lang.String colName)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MEMBER_DATASTORE_ID

public static int MEMBER_DATASTORE_ID

MEMBER_VERSION

public static int MEMBER_VERSION

MEMBER_DISCRIMINATOR

public static int MEMBER_DISCRIMINATOR
Constructor Detail

StatementClassMapping

public StatementClassMapping()

StatementClassMapping

public StatementClassMapping(java.lang.String className,
                             java.lang.String memberName)

StatementClassMapping

public StatementClassMapping(java.lang.String memberName)
Method Detail

getClassName

public java.lang.String getClassName()

getMemberName

public java.lang.String getMemberName()

setNucleusTypeColumnName

public void setNucleusTypeColumnName(java.lang.String colName)

getNucleusTypeColumnName

public java.lang.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.

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()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.