Class SingleCollectionMapping

  • All Implemented Interfaces:
    MappingCallbacks
    Direct Known Subclasses:
    OptionalMapping

    public class SingleCollectionMapping
    extends JavaTypeMapping
    implements MappingCallbacks
    Maps single collection elements as 1-1 instead of 1-N, by wrapping and reusing the JavaTypeMappings and member metadata of the element types.
    • Constructor Detail

      • SingleCollectionMapping

        public SingleCollectionMapping()
    • Method Detail

      • initialize

        public void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                               Table table,
                               org.datanucleus.ClassLoaderResolver clr)
        Description copied from class: JavaTypeMapping
        Initialize this JavaTypeMapping for the supplied table and field/property metadata. Subclasses should override this method to perform any datastore initialization operations. Assumes the "roleForMember" is already set
        Overrides:
        initialize in class JavaTypeMapping
        Parameters:
        mmd - MetaData for the field/property to be mapped (if any)
        table - The table storing this mapping (if any)
        clr - the ClassLoaderResolver
      • setMemberMetaData

        public void setMemberMetaData​(org.datanucleus.metadata.AbstractMemberMetaData mmd)
        Description copied from class: JavaTypeMapping
        Method to set the metadata of the member for which this mapping applies. For use where the mapping was created for a particular type (using the initialize(StoreManager, String) and we now have the member that it applies for.
        Overrides:
        setMemberMetaData in class JavaTypeMapping
        Parameters:
        mmd - Field/Property MetaData
      • includeInFetchStatement

        public boolean includeInFetchStatement()
        Description copied from class: JavaTypeMapping
        Accessor for whether this mapping is to be included in any fetch statement.
        Overrides:
        includeInFetchStatement in class JavaTypeMapping
        Returns:
        Whether to include this mapping in a fetch statement
      • hasSimpleDatastoreRepresentation

        public boolean hasSimpleDatastoreRepresentation()
        Description copied from class: JavaTypeMapping
        Whether the mapping has a simple (single column) datastore representation.
        Overrides:
        hasSimpleDatastoreRepresentation in class JavaTypeMapping
        Returns:
        Whether it has a simple datastore representation (single column)
      • setObject

        public void setObject​(org.datanucleus.ExecutionContext ec,
                              PreparedStatement ps,
                              int[] pos,
                              Object container)
        Description copied from class: JavaTypeMapping
        Sets a value into datastoreStatement at position specified by exprIndex.
        Overrides:
        setObject in class JavaTypeMapping
        Parameters:
        ec - ExecutionContext
        ps - PreparedStatement
        pos - the position of the value in the statement
        container - the value
      • getObject

        public Object getObject​(org.datanucleus.ExecutionContext ec,
                                ResultSet rs,
                                int[] exprIndex)
        Description copied from class: JavaTypeMapping
        Obtains a value from datastoreResults at position specified by exprIndex.
        Overrides:
        getObject in class JavaTypeMapping
        Parameters:
        ec - ExecutionContext
        rs - ResultSet
        exprIndex - the position of the value in the result
        Returns:
        the value
      • getObject

        public Object getObject​(org.datanucleus.ExecutionContext ec,
                                ResultSet rs,
                                int[] exprIndex,
                                org.datanucleus.state.DNStateManager ownerSM,
                                int ownerFieldNumber)
        Description copied from class: JavaTypeMapping
        Obtains a value from the result set at position specified by exprIndex based on being embedded/serialised into the provided owner.
        Overrides:
        getObject in class JavaTypeMapping
        Parameters:
        ec - ExecutionContext
        rs - an object returned from the datastore with values
        exprIndex - the position of the value in the result set
        ownerSM - the owner StateManager where this is embedded
        ownerFieldNumber - the owner field number where this is embedded
        Returns:
        the value
      • getJavaTypeForColumnMapping

        public String getJavaTypeForColumnMapping​(int index)
        Description copied from class: JavaTypeMapping
        Accessor for the name of the java-type actually used when mapping the particular column. This java-type must have an entry in the column mappings. The default implementation throws an UnsupportedOperationException.
        Overrides:
        getJavaTypeForColumnMapping in class JavaTypeMapping
        Parameters:
        index - requested column index.
        Returns:
        the name of java-type for the requested column.
      • postInsert

        public void postInsert​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the insert of the object so that additional operations can be performed if necessary.
        Specified by:
        postInsert in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • postFetch

        public void postFetch​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the retrieval of the object, so that additional operations can be performed if necessary.
        Specified by:
        postFetch in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • postUpdate

        public void postUpdate​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the update of the object, so that additional operations can be performed if necessary.
        Specified by:
        postUpdate in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • preDelete

        public void preDelete​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called before the delete of objects, so that additional operations can be performed if necessary.
        Specified by:
        preDelete in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • getJavaType

        public Class getJavaType()
        Description copied from class: JavaTypeMapping
        Accessor for the java type being mapped. This is the java type that the mapping represents. Some examples :
        • if the field is of type "MyClass" then the mapping will be OIDMapping (or subclass) the javaType will be OID, and the type will be MyClass.
        • if the field is of type "int" then the mapping will be IntegerMapping, the javaType will be Integer, and the type will be int.
        The "java type" is the java-type name used in the plugin.xml mapping file
        Specified by:
        getJavaType in class JavaTypeMapping
        Returns:
        The java type