Class PersistableMapping

    • Field Detail

      • cmd

        protected org.datanucleus.metadata.AbstractClassMetaData cmd
        ClassMetaData for the represented class; creating a new one on each getObject invoke is expensive
    • Constructor Detail

      • PersistableMapping

        public PersistableMapping()
        Create a new empty PersistableMapping. The caller must call one of the initialize methods to initialize the instance with the DatastoreAdapter and its type.
    • Method Detail

      • 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
      • getClassMetaData

        public org.datanucleus.metadata.AbstractClassMetaData getClassMetaData()
        Metadata for the class that this represents an object of.
        Returns:
        ClassMetaData
      • initialize

        public void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                               Table table,
                               org.datanucleus.ClassLoaderResolver clr)
        Initialize this JavaTypeMapping with the given DatastoreAdapter for the given metadata.
        Overrides:
        initialize in class JavaTypeMapping
        Parameters:
        mmd - MetaData for the field/property to be mapped (if any)
        table - The datastore container storing this mapping (if any)
        clr - the ClassLoaderResolver
      • initialize

        public void initialize​(RDBMSStoreManager storeMgr,
                               String type)
        Description copied from class: JavaTypeMapping
        Initialise this JavaTypeMapping with the given StoreManager for the given type. Used when the mapping is for a parameter in a query. This will not set the "mmd" and "datastoreContainer" parameters. If these are required for usage of the mapping then you should call "setFieldInformation(AbstractMemberMetaData, DatastoreContainerObject)" below Subclasses should override this method to perform any datastore initialization operations.
        Overrides:
        initialize in class JavaTypeMapping
        Parameters:
        storeMgr - The Datastore Adapter that this Mapping should use.
        type - The Class that this mapping maps to the database.
      • prepareColumnMapping

        protected void prepareColumnMapping​(org.datanucleus.ClassLoaderResolver clr)
        Method to prepare the PC mapping and add its associated column mappings.
        Parameters:
        clr - The ClassLoaderResolver
      • getValueForColumnMapping

        public Object getValueForColumnMapping​(org.datanucleus.NucleusContext nucleusCtx,
                                               int index,
                                               Object value)
        Method to return the value to be stored in the specified datastore index given the overall value for this java type.
        Overrides:
        getValueForColumnMapping in class JavaTypeMapping
        Parameters:
        nucleusCtx - Context
        index - The datastore index
        value - The overall value for this java type
        Returns:
        The value for this datastore index
      • setObject

        public void setObject​(org.datanucleus.ExecutionContext ec,
                              PreparedStatement ps,
                              int[] param,
                              Object value)
        Method to set an object in the datastore.
        Overrides:
        setObject in class JavaTypeMapping
        Parameters:
        ec - The ExecutionContext
        ps - The Prepared Statement
        param - The parameter ids in the statement
        value - The value to put in the statement at these ids
        Throws:
        org.datanucleus.exceptions.NotYetFlushedException - if an object hasn't yet been flushed to the datastore
      • setObject

        public void setObject​(org.datanucleus.ExecutionContext ec,
                              PreparedStatement ps,
                              int[] param,
                              Object value,
                              org.datanucleus.state.ObjectProvider ownerOP,
                              int ownerFieldNumber)
        Method to set an object reference (FK) in the datastore.
        Overrides:
        setObject in class JavaTypeMapping
        Parameters:
        ec - The ExecutionContext
        ps - The Prepared Statement
        param - The parameter ids in the statement
        value - The value to put in the statement at these ids
        ownerOP - ObjectProvider for the owner object
        ownerFieldNumber - Field number of this PC object in the owner
        Throws:
        org.datanucleus.exceptions.NotYetFlushedException - if an object hasn't yet been flushed to the datastore
      • getObject

        public Object getObject​(org.datanucleus.ExecutionContext ec,
                                ResultSet rs,
                                int[] resultIndexes)
        Returns an instance of a persistable class. Processes the FK field and generates the id of the object from the result values, and hence the object itself. TODO Pass in the discriminator/version columns also where available
        Overrides:
        getObject in class JavaTypeMapping
        Parameters:
        ec - execution context
        rs - The ResultSet
        resultIndexes - indexes in the ResultSet to retrieve
        Returns:
        The persistable object
      • postFetch

        public void postFetch​(org.datanucleus.state.ObjectProvider op)
        Method executed just after a fetch of the owning object, allowing any necessary action to this field and the object stored in it.
        Specified by:
        postFetch in interface MappingCallbacks
        Parameters:
        op - ObjectProvider for the owner.
      • insertPostProcessing

        public void insertPostProcessing​(org.datanucleus.state.ObjectProvider op)
        Description copied from class: JavaTypeMapping
        Perform any INSERT post processing as required by constituent ColumnMappings. TODO Not yet utilised, see RDBMS-14
        Specified by:
        insertPostProcessing in interface MappingCallbacks
        Overrides:
        insertPostProcessing in class JavaTypeMapping
        Parameters:
        op - ObjectProvider of the object with this mapping
      • postInsert

        public void postInsert​(org.datanucleus.state.ObjectProvider op)
        Method executed just after the insert of the owning object, allowing any necessary action to this field and the object stored in it.
        Specified by:
        postInsert in interface MappingCallbacks
        Parameters:
        op - ObjectProvider for the owner
      • postUpdate

        public void postUpdate​(org.datanucleus.state.ObjectProvider op)
        Method executed just afer any update of the owning object, allowing any necessary action to this field and the object stored in it.
        Specified by:
        postUpdate in interface MappingCallbacks
        Parameters:
        op - ObjectProvider for the owner
      • preDelete

        public void preDelete​(org.datanucleus.state.ObjectProvider op)
        Method executed just before the owning object is deleted, allowing tidying up of any relation information.
        Specified by:
        preDelete in interface MappingCallbacks
        Parameters:
        op - ObjectProvider for the owner