Class PersistableMapping

    • Field Detail

      • cmd

        protected org.datanucleus.metadata.AbstractClassMetaData cmd
        ClassMetaData for the represented class.
    • 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.DNStateManager ownerSM,
                              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
        value - The value to put in the statement at these ids
        ownerSM - StateManager for the owner object
        ownerFieldNumber - Field number of this PC object in the owner
        param - The parameter ids in the statement
        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
      • 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
      • 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